From 7333051ec9b32ff7137322bac789a6125792786d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 09:09:26 +0000 Subject: [PATCH 01/85] Auto-generated commit d70423bdc94f9d6807006029fe1f913530654fa6 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 250 +++++ index.d.ts | 54 + index.mjs | 4 + index.mjs.map | 1 + package.json | 38 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3546 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..631844c --- /dev/null +++ b/README.md @@ -0,0 +1,250 @@ + + +# ndarray2array + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Convert an ndarray buffer to a generic array. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; +``` + +#### ndarray2array( buffer, shape, strides, offset, order ) + +Converts an ndarray buffer to a generic array (which may include nested arrays). + +```javascript +var buffer = [ 1, 2, 3, 4 ]; +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 0; + +var arr = ndarray2array( buffer, shape, strides, offset, order ); +// returns [ [ 1, 2 ], [ 3, 4 ] ] +``` + +The `order` parameter specifies whether an array is `row-major` (C-style) or `column-major` (Fortran-style). + +```javascript +var buffer = [ 1, 2, 3, 4 ]; +var shape = [ 2, 2 ]; +var order = 'column-major'; +var strides = [ 1, 2 ]; +var offset = 0; + +var arr = ndarray2array( buffer, shape, strides, offset, order ); +// returns [ [ 1, 3 ], [ 2, 4 ] ] +``` + +The `offset` parameter specifies the location of the first indexed element based on the `strides` array. + +```javascript +var buffer = [ 1, 2, 3, 4 ]; +var shape = [ 2, 2 ]; +var order = 'row-major'; +var strides = [ -2, -1 ]; +var offset = 3; + +var arr = ndarray2array( buffer, shape, strides, offset, order ); +// returns [ [ 4, 3 ], [ 2, 1 ] ] +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## 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..e9e6e69 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,54 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 2.0 + +/// +/// + +import { ArrayLike } from '@stdlib/types/array'; +import { Order } from '@stdlib/types/ndarray'; +import { Buffer } from 'buffer'; + + +/** +* Converts an ndarray buffer to a generic array (which may include nested arrays). +* +* @param buffer - data buffer +* @param shape - array shape +* @param strides - array strides +* @param offset - index offset +* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) +* @returns array (which may include nested arrays) +* +* @example +* var buffer = [ 1, 2, 3, 4 ]; +* var shape = [ 2, 2 ]; +* var order = 'row-major'; +* var strides = [ 2, 1 ]; +* var offset = 0; +* +* var out = ndarray2array( buffer, shape, strides, offset, order ); +* // returns [ [ 1, 2 ], [ 3, 4 ] ] +*/ +declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length + + +// EXPORTS // + +export = ndarray2array; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..57a4734 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";var t=function r(t,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return t.getter(t.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"],"names":["recurse_1","recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","arraylike2object","require$$0","require$$1","lib","buffer"],"mappings":";;+FA8DA,IAAAA,EA1BA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,GClCJO,EAAmBC,EACnBjB,EAAUkB,EAyCd,ICnBAC,EDGA,SAAwBC,EAAQlB,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASgB,EAAkBI,GAAUlB,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ff65081 --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "@stdlib/ndarray-base-to-array", + "version": "0.0.0", + "description": "Convert an ndarray buffer to a generic array.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/ndarray-base-to-array.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdtypes", + "types", + "base", + "ndarray", + "multidimensional", + "array", + "utilities", + "utility", + "utils", + "util", + "view", + "convert", + "toarray", + "transform", + "nested" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c71754b --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From 4ab4c45b5212c59fd84405587d2615d316e936e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 22:51:12 +0000 Subject: [PATCH 02/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9ce186b..f7363d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex64": "^0.0.x", @@ -94,4 +95,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 90d084de758085445573d5c3cd1c66a97b2e0919 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:06:55 +0000 Subject: [PATCH 03/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2748 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 57a4734..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";var t=function r(t,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return t.getter(t.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"],"names":["recurse_1","recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","arraylike2object","require$$0","require$$1","lib","buffer"],"mappings":";;+FA8DA,IAAAA,EA1BA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,GClCJO,EAAmBC,EACnBjB,EAAUkB,EAyCd,ICnBAC,EDGA,SAAwBC,EAAQlB,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASgB,EAAkBI,GAAUlB,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c71754b..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 64e7f016147f31f388f1c34806699a07210cdfb0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:07:49 +0000 Subject: [PATCH 04/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 371 --- 39 files changed, 2714 insertions(+), 3982 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 ec4f1af..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T22:50:29.192Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 + + ```
@@ -193,7 +186,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3407349..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/ndarray/base/to-array" -click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 725e37e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The function does not compile if provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The function does not compile if provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index affff01..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Random flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 1b764fa..e9e6e69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e7b8285 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index e36a3c6..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Function} obj.getter - element accessor -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.getter( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index f7363d1..575bdad 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-array-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ba813cf --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From af96842c8daa23061b8d0974735079cedac00182 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 18:25:33 +0000 Subject: [PATCH 05/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9ce186b..f7363d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex64": "^0.0.x", @@ -94,4 +95,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From eec98d794b1350bc2c576c4c8b09eba8e35269fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 11:32:13 +0000 Subject: [PATCH 06/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2748 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e7b8285..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ba813cf..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From ac70bf8f418536819772fcf25e179181ae09da15 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 11:33:09 +0000 Subject: [PATCH 07/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 371 --- 39 files changed, 2714 insertions(+), 3982 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 03005aa..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:40:37.361Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 + + ```
@@ -193,7 +186,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3407349..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/ndarray/base/to-array" -click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 725e37e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The function does not compile if provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The function does not compile if provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index affff01..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Random flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 1b764fa..e9e6e69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e7b8285 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index e36a3c6..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Function} obj.getter - element accessor -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.getter( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index f7363d1..575bdad 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-array-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..077f3ed --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From aa9fb231f17e8a2d14353f172de862d1de4d972f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:42:38 +0000 Subject: [PATCH 08/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9ce186b..f7363d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex64": "^0.0.x", @@ -94,4 +95,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 6ab9272437a92ed6cfcbb14e622a6cb39b3ae54d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:56:42 +0000 Subject: [PATCH 09/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2748 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e7b8285..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 077f3ed..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e32fc5ea8312c752eadc85a1518cc9e6356d378e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:57:30 +0000 Subject: [PATCH 10/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 371 --- 38 files changed, 2714 insertions(+), 3947 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 + + ```
@@ -193,7 +186,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3407349..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/ndarray/base/to-array" -click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 725e37e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The function does not compile if provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The function does not compile if provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index affff01..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Random flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 1b764fa..e9e6e69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e7b8285 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index e36a3c6..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Function} obj.getter - element accessor -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.getter( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index f7363d1..575bdad 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-array-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a279748 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From e0d57672f0c9fa4747f79c764e50fc648adb4ed0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:57:02 +0000 Subject: [PATCH 11/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9ce186b..f7363d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex64": "^0.0.x", @@ -94,4 +95,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 75a95530e03a229f344e41949fef3a1b6220c1f5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 18:02:43 +0000 Subject: [PATCH 12/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2748 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e7b8285..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a279748..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 47f3c3d88fbc59f32fd98a25e0e6f865d6c2a350 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 18:03:41 +0000 Subject: [PATCH 13/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 371 --- 39 files changed, 2714 insertions(+), 4021 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 dc6cb48..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:42:53.084Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 + + ```
@@ -193,7 +186,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3407349..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/ndarray/base/to-array" -click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 725e37e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The function does not compile if provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The function does not compile if provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index affff01..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Random flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 1b764fa..e9e6e69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e7b8285 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index e36a3c6..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Function} obj.getter - element accessor -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.getter( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index f7363d1..575bdad 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-array-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9670ed1 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From ec0ad4368968fe5dc3c064f4336b7ffca59e1cde Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:48:44 +0000 Subject: [PATCH 14/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9ce186b..f7363d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex64": "^0.0.x", @@ -94,4 +95,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From eaac55b5e3e1f685723962c91a0022225790affe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 17:21:57 +0000 Subject: [PATCH 15/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2748 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e7b8285..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9670ed1..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 47f1e6542d56c374de74e6bd01e435a83bd36e58 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 17:22:45 +0000 Subject: [PATCH 16/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 371 --- 39 files changed, 2714 insertions(+), 4037 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 643d6fc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:42:57.529Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 + + ```
@@ -193,7 +186,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3407349..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/ndarray/base/to-array" -click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 725e37e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The function does not compile if provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The function does not compile if provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The function does not compile if provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The function does not compile if provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The function does not compile if provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index affff01..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Random flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 1b764fa..e9e6e69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e7b8285 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index e36a3c6..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Function} obj.getter - element accessor -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.getter( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index f7363d1..575bdad 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-array-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f67f654 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 87e978d6f4b2cec7d8e9a9c0e5cc1cf6ed71dee7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:17:32 +0000 Subject: [PATCH 17/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9ce186b..f7363d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex64": "^0.0.x", @@ -94,4 +95,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 9d33c61d9225feda276273b78d70fc48419282af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 21:13:09 +0000 Subject: [PATCH 18/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2748 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e7b8285..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f67f654..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From dd8f5d95a796d9a965c7251e31a9a95dafad6b7b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 21:13:55 +0000 Subject: [PATCH 19/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 371 --- 39 files changed, 2714 insertions(+), 4037 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 5aac305..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:10:29.214Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 + + ```
@@ -193,7 +186,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3407349..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/ndarray/base/to-array" -click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index affff01..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Random flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 1b764fa..e9e6e69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e7b8285 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index e36a3c6..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Function} obj.getter - element accessor -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.getter( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index f7363d1..575bdad 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-array-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..188a27c --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From db0a7c41d27971389cf53ff6c49cf229d6b9bd35 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:01:27 +0000 Subject: [PATCH 20/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9ce186b..f7363d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex64": "^0.0.x", @@ -94,4 +95,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From bfbfe017eb1e99e25e6f8a6be88f839378e0731f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 12:05:43 +0000 Subject: [PATCH 21/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2748 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e7b8285..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,ECRR,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 188a27c..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 319ab6e0c16c6671ddcd2380859afe54bcf00ad2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 12:06:34 +0000 Subject: [PATCH 22/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 371 -- 39 files changed, 4069 insertions(+), 4037 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 f830bb9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:56:01.767Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 09518cf..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: '21 9 * * 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 + + ```
@@ -193,7 +186,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3407349..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/ndarray/base/to-array" -click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index affff01..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Random flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 1b764fa..e9e6e69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e7b8285 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index e36a3c6..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Function} obj.getter - element accessor -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.getter( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index f7363d1..575bdad 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-array-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9cda4eb --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 7978c3254fde1c90bf0f66c6c648705832c22a36 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:41:24 +0000 Subject: [PATCH 23/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9ce186b..f7363d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex64": "^0.0.x", @@ -94,4 +95,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From a0a876fdaefa1de2be6b9624e43b8515bb4addab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 08:51:10 +0000 Subject: [PATCH 24/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4103 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e7b8285..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9cda4eb..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 8acbd93dd8f409c300132efe3703029a2abde15b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 08:52:04 +0000 Subject: [PATCH 25/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 371 -- 39 files changed, 4069 insertions(+), 4058 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 300dab7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:57:00.275Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 09518cf..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: '21 9 * * 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 + + ```
@@ -193,7 +186,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3407349..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/ndarray/base/to-array" -click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index affff01..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Random flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 1b764fa..e9e6e69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e7b8285 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index e36a3c6..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Function} obj.getter - element accessor -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.getter( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index f7363d1..575bdad 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-array-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7284e18 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 70879c28ef6c32ca6852cf63280e2d554298e64a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 02:46:14 +0000 Subject: [PATCH 26/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0603467..8ea2efe 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex64": "^0.0.x", @@ -94,4 +95,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 024548f36f1693338cd334ee194ba9860490b427 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:43:42 +0000 Subject: [PATCH 27/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4103 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e7b8285..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object' ;\nimport recurse from './recurse.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7284e18..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From d6a13385bec68f595c3fa0c28965232a3e496340 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:44:33 +0000 Subject: [PATCH 28/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 371 -- 39 files changed, 4069 insertions(+), 4063 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 67b2af9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:45:41.435Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 09518cf..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: '21 9 * * 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 + + ```
@@ -193,7 +186,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3407349..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/ndarray/base/to-array" -click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index affff01..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Random flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 1b764fa..e9e6e69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e7b8285 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index e36a3c6..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Function} obj.getter - element accessor -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.getter( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 8ea2efe..575bdad 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-array-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c68e2a6 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From b1a27387f0c5752f954e9c8fad36ef795ae0cb66 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 04:17:26 +0000 Subject: [PATCH 29/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 14acb36..2fb0c72 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex64": "^0.0.x", @@ -94,4 +95,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 154214b401429947b541fa0b0603c54fcae2428a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 10:15:27 +0000 Subject: [PATCH 30/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4103 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e7b8285..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,i,f){var s,u,o,l,d;if(f>=e.length)return r.getter(r.data,a);for(o=[],l=e[f],s=n[f],d=0;d)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.getter( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","getter","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,OAAQZ,EAAIa,KAAMV,GAO9B,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c68e2a6..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 9ed41c36e85bd0b01ab92e8f590d9ae6ef4e69fa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 10:16:21 +0000 Subject: [PATCH 31/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 371 -- 39 files changed, 6202 insertions(+), 4074 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 330d7d9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T02:35:06.534Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 09518cf..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: '21 9 * * 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 + + ```
@@ -193,7 +186,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 3407349..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/ndarray/base/to-array" -click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index affff01..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Random flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 1b764fa..e9e6e69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..48683d8 --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 2fb0c72..575bdad 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-array-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/ndarray-base-numel": "^0.0.x", - "@stdlib/ndarray-base-shape2strides": "^0.0.x", - "@stdlib/ndarray-base-strides2offset": "^0.0.x", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..eff9cde --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From cf63794b69119dfb3db63204b6aa409a9761cc5b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 5 Mar 2023 00:11:32 +0000 Subject: [PATCH 32/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6838709..0438631 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.0.2", - "@stdlib/types": "^0.0.14" + "@stdlib/types": "^0.0.14", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-complex64": "^0.0.6", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bda81f99969347c14c54b5bb2a2d605bcc11c6cb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 5 Mar 2023 00:13:57 +0000 Subject: [PATCH 33/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6236 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 48683d8..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index eff9cde..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6a0e98c925c67a0ae68860483fcb0a55045ca7d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 5 Mar 2023 00:14:50 +0000 Subject: [PATCH 34/85] 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 | 798 --- .github/workflows/publish.yml | 236 - .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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 371 -- 38 files changed, 6202 insertions(+), 4208 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 09518cf..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: '21 9 * * 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 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS 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 - - # 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: | - 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@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 + + ```
@@ -193,7 +186,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index e0ff37f..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 1b764fa..e9e6e69 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..48683d8 --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 0438631..3a83351 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-array-array": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-imagf": "^0.0.1", - "@stdlib/complex-realf": "^0.0.1", - "@stdlib/ndarray-base-numel": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2472c32 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From dec23ab483eafdaefd0500858bea2de50d161153 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:43:28 +0000 Subject: [PATCH 35/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 15f2b67..ea6f4ac 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/array-complex64": "^0.1.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6396fa8111b12b0e55757591e8a30ff7cfb6c1be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:08:27 +0000 Subject: [PATCH 36/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6236 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 e9e6e69..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 48683d8..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2472c32..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7b129c3c29cea765bf8e6b82225900be0e49bc3b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:10:20 +0000 Subject: [PATCH 37/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 371 -- 42 files changed, 6202 insertions(+), 4251 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 09de76e..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/ndarray/base/to-array) 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 6cfb044..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/ndarray/base/to-array) 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 09518cf..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: '21 9 * * 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 + + ```
@@ -204,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index e0ff37f..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 637eb82..4a86494 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..48683d8 --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index ea6f4ac..e9ffc01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-array-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "@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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..eba3774 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From a81d8116033b0d5369f1ffc6ad82ff75030209d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:22:23 +0000 Subject: [PATCH 38/85] 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 6c35660..2243efd 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs'; ``` #### ndarray2array( buffer, shape, strides, offset, order ) @@ -125,7 +125,7 @@ var arr = ndarray2array( buffer, shape, strides, offset, order ); import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs'; // Create a data buffer: var buffer = []; From 65e83f9d45daf7a96f528e0708cf542166c93eed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:22:24 +0000 Subject: [PATCH 39/85] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2243efd..09d4735 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-base-to-array/tags). For example, + ```javascript import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs'; ``` @@ -125,7 +130,7 @@ var arr = ndarray2array( buffer, shape, strides, offset, order ); import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; // Create a data buffer: var buffer = []; From 7b1e6df9be9fb7f03904a182786f35078f20dc84 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 17:20:46 +0000 Subject: [PATCH 40/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 38e6472..877c7da 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/array-complex64": "^0.1.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f65f1f8caef6bba0ccd140c782ed808f48b77a85 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:46:21 +0000 Subject: [PATCH 41/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6236 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 4a86494..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 48683d8..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index eba3774..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cae15e84c998c8ca6ef3262577a3b529b9fb1db6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:49:28 +0000 Subject: [PATCH 42/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 371 -- test/test.js | 371 -- 44 files changed, 6202 insertions(+), 4681 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 8620e61..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:37:48.431Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 8a8da0c..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: '21 9 * * 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 + + ```
@@ -204,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index e0ff37f..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 637eb82..4a86494 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0230dd7 --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 877c7da..e9ffc01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-array-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2b65f2a --- /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 81553db..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From d78ded1506ae5be7110db0dab6ed22c5cb715e55 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 20:27:58 +0000 Subject: [PATCH 43/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2d95e58..5056752 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex64": "^0.1.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7aa5db5f72892f655ab474d59d38cd1e7daabdda Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:51:03 +0000 Subject: [PATCH 44/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6236 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 4a86494..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0230dd7..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2b65f2a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 05c797ab6b28ebf940b32f872a7000cb6a57fe04 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:53:50 +0000 Subject: [PATCH 45/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 371 -- test/test.js | 371 -- 43 files changed, 6202 insertions(+), 4680 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 8a8da0c..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: '21 9 * * 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 + + ```
@@ -204,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index e0ff37f..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 637eb82..4a86494 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0230dd7 --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 5056752..e9ffc01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-array-array": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0068858 --- /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 81553db..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 433505a30c096d21306120ed4ec1d269f9899ee0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 18:13:03 +0000 Subject: [PATCH 46/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bc19218..6904813 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex64": "^0.1.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f5371fff8be6363631ad43db4ecf8aed07e66550 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 03:07:17 +0000 Subject: [PATCH 47/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6236 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 4a86494..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0230dd7..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0068858..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b3e003353d07438b0c5bff8d49faa702351ccfc9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 03:10:02 +0000 Subject: [PATCH 48/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 44 files changed, 6202 insertions(+), 4351 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 4137380..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:59:14.167Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 8a8da0c..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: '21 9 * * 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 + + ```
@@ -204,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index e0ff37f..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index 637eb82..4a86494 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0230dd7 --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 6904813..e9ffc01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-array-array": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..39502f8 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 35efcf3c3072addad1b75f3a30394f90d554fdcb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 14:22:21 +0000 Subject: [PATCH 49/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 47b9c1e..e633f63 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex64": "^0.1.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3b8a87355d0d1d424cb3c99ec19365197c65e449 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:39:00 +0000 Subject: [PATCH 50/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6236 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 4a86494..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0230dd7..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 39502f8..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cf9d1b05c1888a761837080090b65eb4963cbdb6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:41:45 +0000 Subject: [PATCH 51/85] 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 | 39 +- benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 44 files changed, 6202 insertions(+), 4346 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 bb0e120..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T06:04:24.867Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 8a8da0c..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: '21 9 * * 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 + + ```
@@ -204,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 4aa587d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index e0ff37f..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index e415783..c924c93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0230dd7 --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index e633f63..e9ffc01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-array-array": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2d454f3 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From f6ccd7549c4b851a33d9e62f90c7dac4cbf4ac32 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:37:46 +0000 Subject: [PATCH 52/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9dd30d3..bf71967 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex64": "^0.1.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d350cf56de047cbcfafc5839269379918122e1cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:12:46 +0000 Subject: [PATCH 53/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6236 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 c924c93..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0230dd7..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2d454f3..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 748b013b43182a4c0aab1c9fc22f94d88b05d4bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:13:03 +0000 Subject: [PATCH 54/85] 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 | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 45 files changed, 6202 insertions(+), 4352 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 b476b85..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:34:05.263Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 411ef92..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: '21 9 * * 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 + + ```
@@ -204,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 13ba8af..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index e0ff37f..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index e415783..c924c93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..143112b --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index bf71967..e9ffc01 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.1.0", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-array-array": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0c18485 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From a63efa47995cc9d089be79f3df7fd5791e5bee90 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 01:25:22 +0000 Subject: [PATCH 55/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a53860b..dcc4d4b 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.2.0", - "@stdlib/types": "^0.3.1" + "@stdlib/types": "^0.3.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/array-complex64": "^0.1.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From dcd1d6b3c50ba107b1fd8e4cc2b3653b25635fe4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:55:14 +0000 Subject: [PATCH 56/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6236 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 c924c93..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 143112b..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0c18485..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0b3c1bd3bd9154c78bf8f63f864c7741aedbb984 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:55:50 +0000 Subject: [PATCH 57/85] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 44 files changed, 6202 insertions(+), 4360 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 7a6ac2d..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: '21 9 * * 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 + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 13ba8af..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae2eca..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index e415783..c924c93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..143112b --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index dcc4d4b..368e43c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.0", - "@stdlib/types": "^0.3.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.2.0", - "@stdlib/assert-is-array-array": "^0.2.0", - "@stdlib/complex-imagf": "^0.2.0", - "@stdlib/complex-realf": "^0.2.0", - "@stdlib/ndarray-base-numel": "^0.2.0", - "@stdlib/ndarray-base-shape2strides": "^0.2.0", - "@stdlib/ndarray-base-strides2offset": "^0.2.0", - "@stdlib/random-base-discrete-uniform": "^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.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cf5b005 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 8347c3b5c846e3e4fbda95afff5729c83700a5f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:38:45 +0000 Subject: [PATCH 58/85] 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 109f9a6..1100740 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.0-esm/index.mjs'; ``` #### ndarray2array( buffer, shape, strides, offset, order ) @@ -125,7 +125,7 @@ var arr = ndarray2array( buffer, shape, strides, offset, order ); import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.0-esm/index.mjs'; // Create a data buffer: var buffer = []; From 7f69e03577d9feaa982edab2c696a1deafe1d1a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:38:45 +0000 Subject: [PATCH 59/85] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1100740..43c926b 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-base-to-array/tags). For example, + ```javascript import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.0-esm/index.mjs'; ``` @@ -125,7 +130,7 @@ var arr = ndarray2array( buffer, shape, strides, offset, order ); import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.0-esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; // Create a data buffer: var buffer = []; From f92cae6347d965379e6026d5ff5ae3920943fa5f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:06:07 +0000 Subject: [PATCH 60/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8c8c0da..79ed5ad 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-complex64": "^0.2.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d0fdd2caf60ce0e3985d1865a8f1dee0fec79846 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:25:37 +0000 Subject: [PATCH 61/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6236 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 c924c93..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 143112b..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cf5b005..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 83b4b4f66fb268512b7f757534bf95639c28376a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:25:55 +0000 Subject: [PATCH 62/85] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 44 files changed, 4867 insertions(+), 4354 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 06d8e16..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: '21 9 * * 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 + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 13ba8af..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae2eca..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index e415783..c924c93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ba628b4 --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 79ed5ad..d478468 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-array-array": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^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.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fe00cca --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From e62fc063c3596d5f333b91788ac89006ab1e625a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:04:41 +0000 Subject: [PATCH 63/85] 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 f2d0723..78a0823 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs'; ``` #### ndarray2array( buffer, shape, strides, offset, order ) @@ -125,7 +125,7 @@ var arr = ndarray2array( buffer, shape, strides, offset, order ); import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs'; // Create a data buffer: var buffer = []; From 3965b59024918d81fdc36f1b7b31fe4486379a1e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:04:41 +0000 Subject: [PATCH 64/85] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 78a0823..ab8f136 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/ndarray-base-to-array/tags). For example, + ```javascript import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs'; ``` @@ -125,7 +130,7 @@ var arr = ndarray2array( buffer, shape, strides, offset, order ); import shape2strides from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shape2strides@esm/index.mjs'; import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-strides2offset@esm/index.mjs'; import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs'; // Create a data buffer: var buffer = []; From 24141e750f808c5f3445e409caf58abec23db035 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 08:28:41 +0000 Subject: [PATCH 65/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c5b065f..772afde 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-complex64": "^0.2.1", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 595cee406014304fd7d66712dc7e188e42b973cf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:16:08 +0000 Subject: [PATCH 66/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4901 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 c924c93..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ba628b4..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.0-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index fe00cca..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b585afdf66c1edd72fd5e441f9cd43461833ac15 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:16:28 +0000 Subject: [PATCH 67/85] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 45 files changed, 4867 insertions(+), 4356 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 8df554a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T06:06:58.498Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 06d8e16..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: '21 9 * * 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 + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 13ba8af..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae2eca..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index e415783..c924c93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8e80bdd --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 772afde..d478468 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-array-array": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9cb496e --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 4eb8de50c7e05870f7ccf17ae4d5461803067b1b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:45:08 +0000 Subject: [PATCH 68/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c5b065f..772afde 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-complex64": "^0.2.1", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1a62a7c178a26507edebd99fd1018db548f4adef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:16:56 +0000 Subject: [PATCH 69/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4901 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 c924c93..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8e80bdd..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;+FAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9cb496e..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f0f90c23c53f8bda74952376435556a247e810ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:17:10 +0000 Subject: [PATCH 70/85] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 45 files changed, 4867 insertions(+), 4359 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 cdd2209..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:22:42.998Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 06d8e16..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: '21 9 * * 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 + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 13ba8af..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae2eca..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index e415783..c924c93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d9bc8ae --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 772afde..d478468 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-array-array": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d2b2310 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From ccff357ac11ea73c78e272377a89da87a9aaa694 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:58:23 +0000 Subject: [PATCH 71/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c5b065f..772afde 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-complex64": "^0.2.1", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 32912a2f750e710472714202f968ec402d8eec6f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:25:48 +0000 Subject: [PATCH 72/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4901 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 c924c93..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d9bc8ae..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d2b2310..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bac846284100d8752f7aef6404b6935853e603b2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:26:06 +0000 Subject: [PATCH 73/85] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 44 files changed, 4867 insertions(+), 4360 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 06d8e16..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: '21 9 * * 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 + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 13ba8af..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae2eca..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index e415783..c924c93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d9bc8ae --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 772afde..d478468 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-array-array": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^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", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d2b2310 --- /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 b83e5c7..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 33a32f6e529753f4fb8bc4f0969c65a2d449a8b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 02:10:48 +0000 Subject: [PATCH 74/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3446759..5b195d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex64": "^0.3.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c432a5792e423d25a5169c4126d280fcef4afd12 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 02:39:08 +0000 Subject: [PATCH 75/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4901 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 c924c93..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d9bc8ae..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d2b2310..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 599359b74b9c5aedd5ee3bd88d2c8ad6fe8ba6da Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Dec 2024 02:39:24 +0000 Subject: [PATCH 76/85] 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 | 211 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 46 files changed, 4867 insertions(+), 4685 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 4bee472..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-23T02:01:58.008Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 06d8e16..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: '21 9 * * 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 + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 13ba8af..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae2eca..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index e415783..c924c93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d9bc8ae --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 5b195d1..d478468 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-array-array": "^0.2.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d2b2310 --- /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 c15fd34..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 738a47aac6c1b7475a8ced81f9b131bc8b9dca64 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Feb 2025 00:30:30 +0000 Subject: [PATCH 77/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3446759..5b195d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex64": "^0.3.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9ebb9ce7335755e79cbdff4f58e7360b85baa77b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Feb 2025 00:35:03 +0000 Subject: [PATCH 78/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4901 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 c924c93..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d9bc8ae..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d2b2310..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d1e091dc2d3220864be9fd55d44434c36d66f06a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Feb 2025 00:35:19 +0000 Subject: [PATCH 79/85] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 211 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 46 files changed, 4867 insertions(+), 4684 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 ec4d8d5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-10T00:29:08.072Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 09de76e..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 06d8e16..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: '21 9 * * 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 + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 13ba8af..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae2eca..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index e415783..c924c93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a1e44bd --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 5b195d1..d478468 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-array-array": "^0.2.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d2b2310 --- /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 c15fd34..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From ffdb0b74d4a6ac84ce34e8d7403cd582c516e908 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:23:46 +0000 Subject: [PATCH 80/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3446759..5b195d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex64": "^0.3.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c09f1a4c8ad20d3faf61efb189529efe67e9533f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:58:03 +0000 Subject: [PATCH 81/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4901 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 c924c93..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a1e44bd..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d2b2310..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d85da4113f7b5ff13cf5c66e0872b7d630bcdbe8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 19 May 2025 01:58:27 +0000 Subject: [PATCH 82/85] 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 | 211 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 46 files changed, 4867 insertions(+), 4688 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 2f2e06c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-19T01:13:43.332Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c0e28b9..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 06d8e16..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: '21 9 * * 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 + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 13ba8af..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae2eca..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index e415783..c924c93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a1e44bd --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 5b195d1..d478468 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-array-array": "^0.2.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d2b2310 --- /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 c15fd34..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From db021b47d234d23b7ca8c00f41571e3dd19adcab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 00:51:35 +0000 Subject: [PATCH 83/85] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3446759..5b195d1 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-complex64": "^0.3.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 329f1298d8ad1661f09ed4f949571254d3221c09 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 01:28:09 +0000 Subject: [PATCH 84/85] Remove files --- index.d.ts | 54 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4901 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 c924c93..0000000 --- a/index.d.ts +++ /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. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { ArrayLike } from '@stdlib/types/array'; -import { Order } from '@stdlib/types/ndarray'; -import { Buffer } from 'buffer'; - - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param buffer - data buffer -* @param shape - array shape -* @param strides - array strides -* @param offset - index offset -* @param order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( buffer: ArrayLike | Buffer, shape: ArrayLike, strides: ArrayLike, offset: number, order: Order ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a1e44bd..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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d2b2310..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 389a34325f013ca46b8196e4c0ab59d0f9a9690a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Jun 2025 01:28:26 +0000 Subject: [PATCH 85/85] 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 | 211 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 113 - benchmark/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 118 - examples/index.js | 60 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 65 - lib/recurse.js | 63 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 371 -- 46 files changed, 4867 insertions(+), 4688 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/numpy/benchmark.py 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 (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/recurse.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 f9fd5ce..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-02T00:50:01.496Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c0e28b9..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/ndarray/base/to-array) 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 fe78c76..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/ndarray/base/to-array) 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 06d8e16..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: '21 9 * * 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 + + ```
@@ -206,7 +197,7 @@ for ( i = 0; i < 20; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 13ba8af..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,113 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - - buffer = []; - for ( i = 0; i < len; i++ ) { - buffer.push( i ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - strides[ 1 ] *= ( randu() < 0.5 ) ? -1 : 1; - out = ndarray2array( buffer, shape, strides, offset, order ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/numpy/benchmark.py b/benchmark/numpy/benchmark.py deleted file mode 100644 index ffcf888..0000000 --- a/benchmark/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2018 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae2eca..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/ndarray/base/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-base-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/to-array -[production-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d56737c..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var y=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=y(function(B,f){ -function l(t,r,u,a,n,e){var v,s,i,o,c;if(e>=r.length)return t.accessors[0](t.data,a);for(i=[],o=r[e],v=u[e],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = recurse;\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// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\nvar recurse = require( './recurse.js' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\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* Convert an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-base-to-array\n*\n* @example\n* var ndarray2array = require( '@stdlib/ndarray-base-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAoCA,SAASC,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAM,CAC3D,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAM,OACjB,OAAOD,EAAI,UAAW,CAAE,EAAGA,EAAI,KAAMG,CAAO,EAO7C,IALAK,EAAM,CAAC,EAEPC,EAAIR,EAAOI,CAAI,EACfC,EAASJ,EAASG,CAAI,EAEhBK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,CAAE,EAC1DG,EAAI,KAAMD,CAAK,EACfJ,GAAUG,EAEX,OAAOE,CACR,CAKAV,EAAO,QAAUC,IC9DjB,IAAAY,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EAClEC,EAAU,IAyBd,SAASC,EAAeC,EAAQC,EAAOC,EAASC,EAAQC,EAAQ,CAC/D,IAAIC,EACJ,GAAKJ,EAAM,SAAW,EACrB,MAAO,CAAC,EAET,IAAMI,EAAI,EAAGA,EAAIJ,EAAM,OAAQI,IAC9B,GAAKJ,EAAOI,CAAE,IAAM,EACnB,MAAO,CAAC,EAGV,OAAOP,EAASD,EAAkBG,CAAO,EAAGC,EAAOC,EAASC,EAAQC,EAAO,CAAE,CAC9E,CAKAR,EAAO,QAAUG,ICxBjB,IAAIO,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_recurse", "__commonJSMin", "exports", "module", "recurse", "obj", "shape", "strides", "offset", "order", "dim", "stride", "item", "out", "n", "i", "require_main", "__commonJSMin", "exports", "module", "arraylike2object", "recurse", "ndarray2array", "buffer", "shape", "strides", "offset", "order", "i", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bb99435..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( buffer, shape, strides, offset, order ) - Converts an ndarray buffer to a generic array. - - Parameters - ---------- - buffer: ArrayLike|TypedArray|Buffer - Array buffer. - - shape: ArrayLike - Array shape. - - strides: ArrayLike - Stride array. - - offset: integer - Location of the first indexed value based on the stride array. - - order: string - Specifies whether an array is row-major (C-style) or column-major - (Fortran-style). - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var b = [ 1, 2, 3, 4 ]; - > var d = [ 2, 2 ]; - > var s = [ 2, 1 ]; - > var o = 0; - > var out = {{alias}}( b, d, s, o, 'row-major' ) - [ [ 1, 2 ], [ 3, 4 ] ] - > out = {{alias}}( b, d, s, o, 'column-major' ) - [ [ 1, 3 ], [ 2, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index f80b7b5..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'row-major' ); // $ExpectType any[] - ndarray2array( [ 1, 2, 3, 4 ], [ 2, 2 ], [ 2, 1 ], 0, 'column-major' ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object or buffer... -{ - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( 123, shape, strides, offset, order ); // $ExpectError - ndarray2array( true, shape, strides, offset, order ); // $ExpectError - ndarray2array( false, shape, strides, offset, order ); // $ExpectError - ndarray2array( null, shape, strides, offset, order ); // $ExpectError - ndarray2array( undefined, shape, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const strides = [ 2, 1 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, true, strides, offset, order ); // $ExpectError - ndarray2array( buffer, false, strides, offset, order ); // $ExpectError - ndarray2array( buffer, null, strides, offset, order ); // $ExpectError - ndarray2array( buffer, undefined, strides, offset, order ); // $ExpectError - ndarray2array( buffer, '5', strides, offset, order ); // $ExpectError - ndarray2array( buffer, [ '1', '2' ], strides, offset, order ); // $ExpectError - ndarray2array( buffer, {}, strides, offset, order ); // $ExpectError - ndarray2array( buffer, ( x: number ): number => x, strides, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not an array-like object containing numbers... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const offset = 0; - const order = 'row-major'; - ndarray2array( buffer, shape, true, offset, order ); // $ExpectError - ndarray2array( buffer, shape, false, offset, order ); // $ExpectError - ndarray2array( buffer, shape, null, offset, order ); // $ExpectError - ndarray2array( buffer, shape, undefined, offset, order ); // $ExpectError - ndarray2array( buffer, shape, '5', offset, order ); // $ExpectError - ndarray2array( buffer, shape, [ '1', '2' ], offset, order ); // $ExpectError - ndarray2array( buffer, shape, {}, offset, order ); // $ExpectError - ndarray2array( buffer, shape, ( x: number ): number => x, offset, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const order = 'row-major'; - ndarray2array( buffer, shape, strides, true, order ); // $ExpectError - ndarray2array( buffer, shape, strides, false, order ); // $ExpectError - ndarray2array( buffer, shape, strides, null, order ); // $ExpectError - ndarray2array( buffer, shape, strides, undefined, order ); // $ExpectError - ndarray2array( buffer, shape, strides, '5', order ); // $ExpectError - ndarray2array( buffer, shape, strides, [ '1', '2' ], order ); // $ExpectError - ndarray2array( buffer, shape, strides, {}, order ); // $ExpectError - ndarray2array( buffer, shape, strides, ( x: number ): number => x, order ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fifth argument which is not a known array order... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array( buffer, shape, strides, offset, true ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, false ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, null ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, undefined ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, '5' ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, [ '1', '2' ] ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, {} ); // $ExpectError - ndarray2array( buffer, shape, strides, offset, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - const buffer = [ 1, 2, 3, 4 ]; - const shape = [ 2, 2 ]; - const strides = [ 2, 1 ]; - const offset = 0; - ndarray2array(); // $ExpectError - ndarray2array( buffer ); // $ExpectError - ndarray2array( buffer, shape ); // $ExpectError - ndarray2array( buffer, shape, strides ); // $ExpectError - ndarray2array( buffer, shape, strides, offset ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 370aa6c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = []; -var i; -for ( i = 0; i < 27; i++ ) { - buffer.push( i ); -} - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray2array( buffer, shape, strides, offset, order ); - console.log( JSON.stringify( arr ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index e415783..c924c93 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a1e44bd --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs";function t(r,e,n,a,s,i){var f,o,u,l,c;if(i>=e.length)return r.accessors[0](r.data,a);for(u=[],l=e[i],f=n[i],c=0;c} obj.accessors - element accessors\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @param {NonNegativeInteger} dim - dimension\n* @returns {(Array|Array)} output array\n*/\nfunction recurse( obj, shape, strides, offset, order, dim ) {\n\tvar stride;\n\tvar item;\n\tvar out;\n\tvar n;\n\tvar i;\n\n\tif ( dim >= shape.length ) {\n\t\treturn obj.accessors[ 0 ]( obj.data, offset );\n\t}\n\tout = [];\n\n\tn = shape[ dim ];\n\tstride = strides[ dim ];\n\n\tfor ( i = 0; i < n; i++ ) {\n\t\titem = recurse( obj, shape, strides, offset, order, dim+1 );\n\t\tout.push( item );\n\t\toffset += stride;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default recurse;\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// MODULES //\n\nimport arraylike2object from '@stdlib/array-base-arraylike2object';\nimport recurse from './recurse.js';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray buffer to a generic array (which may include nested arrays).\n*\n* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {IntegerArray} strides - array strides\n* @param {NonNegativeInteger} offset - index offset\n* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style)\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var out = ndarray2array( buffer, shape, strides, offset, order );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( buffer, shape, strides, offset, order ) {\n\tvar i;\n\tif ( shape.length === 0 ) {\n\t\treturn [];\n\t}\n\tfor ( i = 0; i < shape.length; i++ ) {\n\t\tif ( shape[ i ] === 0 ) {\n\t\t\treturn [];\n\t\t}\n\t}\n\treturn recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["recurse","obj","shape","strides","offset","order","dim","stride","item","out","n","i","length","accessors","data","push","ndarray2array","buffer","arraylike2object"],"mappings":";;sGAoCA,SAASA,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,GACrD,IAAIC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKL,GAAOJ,EAAMU,OACjB,OAAOX,EAAIY,UAAW,GAAKZ,EAAIa,KAAMV,GAOtC,IALAK,EAAM,GAENC,EAAIR,EAAOI,GACXC,EAASJ,EAASG,GAEZK,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAOR,EAASC,EAAKC,EAAOC,EAASC,EAAQC,EAAOC,EAAI,GACxDG,EAAIM,KAAMP,GACVJ,GAAUG,EAEX,OAAOE,CACR,CCTA,SAASO,EAAeC,EAAQf,EAAOC,EAASC,EAAQC,GACvD,IAAIM,EACJ,GAAsB,IAAjBT,EAAMU,OACV,MAAO,GAER,IAAMD,EAAI,EAAGA,EAAIT,EAAMU,OAAQD,IAC9B,GAAoB,IAAfT,EAAOS,GACX,MAAO,GAGT,OAAOX,EAASkB,EAAkBD,GAAUf,EAAOC,EAASC,EAAQC,EAAO,EAC5E"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index df4b1fe..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray buffer to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-base-to-array -* -* @example -* var ndarray2array = require( '@stdlib/ndarray-base-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index ae7387b..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var recurse = require( './recurse.js' ); - - -// MAIN // - -/** -* Converts an ndarray buffer to a generic array (which may include nested arrays). -* -* @param {(ArrayLikeObject|TypedArray|Buffer)} buffer - data buffer -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var out = ndarray2array( buffer, shape, strides, offset, order ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( buffer, shape, strides, offset, order ) { - var i; - if ( shape.length === 0 ) { - return []; - } - for ( i = 0; i < shape.length; i++ ) { - if ( shape[ i ] === 0 ) { - return []; - } - } - return recurse( arraylike2object( buffer ), shape, strides, offset, order, 0 ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/recurse.js b/lib/recurse.js deleted file mode 100644 index 6746afd..0000000 --- a/lib/recurse.js +++ /dev/null @@ -1,63 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Recursively converts an ndarray to a generic array. -* -* @private -* @param {Object} obj - array object -* @param {(ArrayLikeObject|TypedArray|Buffer)} obj.data - data buffer -* @param {Array} obj.accessors - element accessors -* @param {NonNegativeIntegerArray} shape - array shape -* @param {IntegerArray} strides - array strides -* @param {NonNegativeInteger} offset - index offset -* @param {string} order - specifies whether an array is row-major (C-style) or column-major (Fortran-style) -* @param {NonNegativeInteger} dim - dimension -* @returns {(Array|Array)} output array -*/ -function recurse( obj, shape, strides, offset, order, dim ) { - var stride; - var item; - var out; - var n; - var i; - - if ( dim >= shape.length ) { - return obj.accessors[ 0 ]( obj.data, offset ); - } - out = []; - - n = shape[ dim ]; - stride = strides[ dim ]; - - for ( i = 0; i < n; i++ ) { - item = recurse( obj, shape, strides, offset, order, dim+1 ); - out.push( item ); - offset += stride; - } - return out; -} - - -// EXPORTS // - -module.exports = recurse; diff --git a/package.json b/package.json index 5b195d1..d478468 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray buffer to a generic 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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.2.1", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-array-array": "^0.2.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -90,9 +31,8 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d2b2310 --- /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 c15fd34..0000000 --- a/test/test.js +++ /dev/null @@ -1,371 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty buffer/shape', function test( t ) { - var out = ndarray2array( [], [], [], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided a dimension which has zero elements', function test( t ) { - var out = ndarray2array( [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray buffer to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - out = ndarray2array( buffer, shape, strides, offset, order ); - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -});