From cf217ffe9dc03a9f48f0f0a91d575f23f6b2e508 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 09:25:05 +0000 Subject: [PATCH 001/115] Auto-generated commit ea3be5f37be0fd636e50dd45328832613481aef6 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 211 ++++ index.d.ts | 89 ++ index.mjs | 4 + index.mjs.map | 1 + package.json | 36 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3540 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..cbfed53 --- /dev/null +++ b/README.md @@ -0,0 +1,211 @@ + + +# arraylike2object + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Convert an array-like object to an object likely to have the same "shape". + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import arraylike2object from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs'; +``` + +#### arraylike2object( x ) + +Converts an array-like object to an object likely to have the same "shape". + +```javascript +var obj = arraylike2object( [ 1, 2, 3, 4 ] ); +// returns {...} +``` + +
+ + + + + +
+ +## Notes + +- The returned object has the following properties: + + - **data**: data buffer. + - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements. + - **getter**: accessor for retrieving a data buffer element. + - **setter**: accessor for setting a data buffer element. + +- The getter accessor accepts two arguments: + + - **data**: data buffer. + - **idx**: element index. + +- The setter accessor accepts three arguments: + + - **data**: data buffer. + - **idx**: element index. + - **value**: value to set. + +- This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". + +
+ + + + + +
+ +## 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..4c5f800 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,89 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2022 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 { Collection } from '@stdlib/types/object'; + +/** +* Returns an array element. +* +* @param data - array data +* @param idx - element index +* @returns element value +*/ +type Getter = ( data: Collection, idx: number ) => any; + +/** +* Sets an array element. +* +* @param data - array data +* @param idx - element index +* @param value - value to set +*/ +type Setter = ( data: Collection, idx: number, value: any ) => void; + +/** +* Interface describing the output object. +*/ +interface ArrayObject { + /** + * Data buffer. + */ + data: Collection; + + /** + * Boolean indicating whether the data buffer uses accessors for getting and setting elements. + */ + accessors: boolean; + + /** + * Accessor for retrieving a data buffer element. + */ + getter: Getter; + + /** + * Accessor for setting a data buffer element. + */ + setter: Setter; +} + +/** +* Converts a one-dimensional array-like object to an object likely to have the same "shape". +* +* ## Notes +* +* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". +* +* @param x - input array +* @returns object containing array data +* +* @example +* var x = [ 1, 2, 3, 4, 5, 6 ]; +* +* var obj = arraylike2object( x ); +* // returns {...} +*/ +declare function arraylike2object( x: Collection ): ArrayObject; + + +// EXPORTS // + +export = arraylike2object; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..41ac6bb --- /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 +/// +var t=function(t,e){return t[e]},e=function(t,e){return t.get(e)},n=function(t,e,n){t[e]=n},r=function(t,e,n){t.set(n,e)};var a=function(a){var o=Boolean(a.get&&a.set);return{data:a,accessors:o,getter:o?e:t,setter:o?r:n}};export{a as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0159339 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/setter.accessor.js","../lib/main.js","../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 getIndexed = require( './getter.js' );\nvar getAccessor = require( './getter.accessor.js' );\nvar setIndexed = require( './setter.js' );\nvar setAccessor = require( './setter.accessor.js' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["getIndexed","x","idx","getAccessor","get","setIndexed","value","setAccessor","set","lib","bool","Boolean","data","accessors","getter","setter"],"mappings":";;AAqCA,ICfIA,ECQJ,SAAiBC,EAAGC,GACnB,OAAOD,EAAGC,IDRPC,EEOJ,SAAiBF,EAAGC,GACnB,OAAOD,EAAEG,IAAKF,IFPXG,EGMJ,SAAiBJ,EAAGC,EAAKI,GACxBL,EAAGC,GAAQI,GHNRC,EDKJ,SAAiBN,EAAGC,EAAKI,GACxBL,EAAEO,IAAKF,EAAOJ,ICiCf,IIzBAO,EJYA,SAA2BR,GAC1B,IAAIS,EAAOC,QAASV,EAAEG,KAAOH,EAAEO,KAC/B,MAAO,CACNI,KAAQX,EACRY,UAAaH,EACbI,OAAU,EAAWX,EAAcH,EACnCe,OAAU,EAAWR,EAAcF"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..6a585c5 --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "@stdlib/array-base-arraylike2object", + "version": "0.0.0", + "description": "Convert an array-like object to an object likely to have the same \"shape\".", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/array-base-arraylike2object.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdtypes", + "types", + "base", + "array", + "standardize", + "shape", + "hidden", + "objectify", + "meta", + "utilities", + "utility", + "utils", + "util" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1c98742 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From e74868178ddcb631a7c20a604f4cb6d268089786 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 23:07:35 +0000 Subject: [PATCH 002/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3d8b66b..c3347f9 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.x", @@ -88,4 +89,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 116064790fc8160e82c13ec3d79dcd200967ac8a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 10:30:22 +0000 Subject: [PATCH 003/115] Remove files --- index.d.ts | 89 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2783 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 4c5f800..0000000 --- a/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/object'; - -/** -* Returns an array element. -* -* @param data - array data -* @param idx - element index -* @returns element value -*/ -type Getter = ( data: Collection, idx: number ) => any; - -/** -* Sets an array element. -* -* @param data - array data -* @param idx - element index -* @param value - value to set -*/ -type Setter = ( data: Collection, idx: number, value: any ) => void; - -/** -* Interface describing the output object. -*/ -interface ArrayObject { - /** - * Data buffer. - */ - data: Collection; - - /** - * Boolean indicating whether the data buffer uses accessors for getting and setting elements. - */ - accessors: boolean; - - /** - * Accessor for retrieving a data buffer element. - */ - getter: Getter; - - /** - * Accessor for setting a data buffer element. - */ - setter: Setter; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var obj = arraylike2object( x ); -* // returns {...} -*/ -declare function arraylike2object( x: Collection ): ArrayObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 41ac6bb..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 -/// -var t=function(t,e){return t[e]},e=function(t,e){return t.get(e)},n=function(t,e,n){t[e]=n},r=function(t,e,n){t.set(n,e)};var a=function(a){var o=Boolean(a.get&&a.set);return{data:a,accessors:o,getter:o?e:t,setter:o?r:n}};export{a as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0159339..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/setter.accessor.js","../lib/main.js","../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 getIndexed = require( './getter.js' );\nvar getAccessor = require( './getter.accessor.js' );\nvar setIndexed = require( './setter.js' );\nvar setAccessor = require( './setter.accessor.js' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nmodule.exports = getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nmodule.exports = setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["getIndexed","x","idx","getAccessor","get","setIndexed","value","setAccessor","set","lib","bool","Boolean","data","accessors","getter","setter"],"mappings":";;AAqCA,ICfIA,ECQJ,SAAiBC,EAAGC,GACnB,OAAOD,EAAGC,IDRPC,EEOJ,SAAiBF,EAAGC,GACnB,OAAOD,EAAEG,IAAKF,IFPXG,EGMJ,SAAiBJ,EAAGC,EAAKI,GACxBL,EAAGC,GAAQI,GHNRC,EDKJ,SAAiBN,EAAGC,EAAKI,GACxBL,EAAEO,IAAKF,EAAOJ,ICiCf,IIzBAO,EJYA,SAA2BR,GAC1B,IAAIS,EAAOC,QAASV,EAAEG,KAAOH,EAAEO,KAC/B,MAAO,CACNI,KAAQX,EACRY,UAAaH,EACbI,OAAU,EAAWX,EAAcH,EACnCe,OAAU,EAAWR,EAAcF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1c98742..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 7a98e8038b768b057b273960b91696b658218dfa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 10:31:04 +0000 Subject: [PATCH 004/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 46 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/getter.accessor.js | 38 - lib/getter.js | 38 - lib/index.js | 40 - lib/main.js | 65 - lib/setter.accessor.js | 38 - lib/setter.js | 38 - package.json | 62 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 125 - 41 files changed, 2712 insertions(+), 3589 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 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/getter.accessor.js delete mode 100644 lib/getter.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/setter.accessor.js delete mode 100644 lib/setter.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 ebf3fbe..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T22:50:14.874Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -154,7 +147,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index bddbd7e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index f50d648..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: data buffer. - - accessors: boolean indicating whether the data buffer uses accessors for - getting and setting elements. - - getter: accessor for retrieving a data buffer element. - - setter: accessor for setting a data buffer element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5c5cf31..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arraylike2object = require( './index' ); - - -// TESTS // - -// The function returns an array object... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x ); // $ExpectType ArrayObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0c7d9c8..4c5f800 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..90532e6 --- /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 +/// +function t(t,e){return t[e]}function e(t,e){return t.get(e)}function n(t,e,n){t[e]=n}function r(t,e,n){t.set(n,e)}function o(o){var u=Boolean(o.get&&o.set);return{data:o,accessors:u,getter:u?e:t,setter:u?r:n}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..37e9e0e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;AA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCoBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,QAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/lib/getter.accessor.js b/lib/getter.accessor.js deleted file mode 100644 index aca5b1c..0000000 --- a/lib/getter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x.get( idx ); -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index 8a08c81..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x[ idx ]; -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 9099d34..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var getIndexed = require( './getter.js' ); -var getAccessor = require( './getter.accessor.js' ); -var setIndexed = require( './setter.js' ); -var setAccessor = require( './setter.accessor.js' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: data buffer. -* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements. -* - **getter**: accessor for retrieving a data buffer element. -* - **setter**: accessor for setting a data buffer element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance. - return { - 'data': x, - 'accessors': bool, - 'getter': ( bool ) ? getAccessor : getIndexed, - 'setter': ( bool ) ? setAccessor : setIndexed - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/lib/setter.accessor.js b/lib/setter.accessor.js deleted file mode 100644 index 60ba427..0000000 --- a/lib/setter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x.set( value, idx ); -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index b4bdd2a..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x[ idx ] = value; -} - - -// EXPORTS // - -module.exports = setter; diff --git a/package.json b/package.json index c3347f9..efe6ee4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,38 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^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", @@ -84,9 +29,8 @@ "utils", "util" ], - "__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..6c5f206 --- /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 0bee513..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessors': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From a619daff08d2d63b560cebafad38cb51293890fc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 18:39:33 +0000 Subject: [PATCH 005/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3d8b66b..c3347f9 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.x", @@ -88,4 +89,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 8dd35301ed7556a1922d4ab5b4d5f7a11cf976aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 06:37:10 +0000 Subject: [PATCH 006/115] Remove files --- index.d.ts | 89 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2783 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 4c5f800..0000000 --- a/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/object'; - -/** -* Returns an array element. -* -* @param data - array data -* @param idx - element index -* @returns element value -*/ -type Getter = ( data: Collection, idx: number ) => any; - -/** -* Sets an array element. -* -* @param data - array data -* @param idx - element index -* @param value - value to set -*/ -type Setter = ( data: Collection, idx: number, value: any ) => void; - -/** -* Interface describing the output object. -*/ -interface ArrayObject { - /** - * Data buffer. - */ - data: Collection; - - /** - * Boolean indicating whether the data buffer uses accessors for getting and setting elements. - */ - accessors: boolean; - - /** - * Accessor for retrieving a data buffer element. - */ - getter: Getter; - - /** - * Accessor for setting a data buffer element. - */ - setter: Setter; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var obj = arraylike2object( x ); -* // returns {...} -*/ -declare function arraylike2object( x: Collection ): ArrayObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 90532e6..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 -/// -function t(t,e){return t[e]}function e(t,e){return t.get(e)}function n(t,e,n){t[e]=n}function r(t,e,n){t.set(n,e)}function o(o){var u=Boolean(o.get&&o.set);return{data:o,accessors:u,getter:u?e:t,setter:u?r:n}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 37e9e0e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;AA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCoBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,QAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6c5f206..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 000e5a715eac73b9065b0a063da72ba5d1a870e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 06:37:54 +0000 Subject: [PATCH 007/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 46 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/getter.accessor.js | 38 - lib/getter.js | 38 - lib/index.js | 40 - lib/main.js | 65 - lib/setter.accessor.js | 38 - lib/setter.js | 38 - package.json | 62 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 125 - 41 files changed, 2712 insertions(+), 3589 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 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/getter.accessor.js delete mode 100644 lib/getter.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/setter.accessor.js delete mode 100644 lib/setter.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 72f85bb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:40:27.082Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -154,7 +147,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index bddbd7e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index f50d648..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: data buffer. - - accessors: boolean indicating whether the data buffer uses accessors for - getting and setting elements. - - getter: accessor for retrieving a data buffer element. - - setter: accessor for setting a data buffer element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5c5cf31..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arraylike2object = require( './index' ); - - -// TESTS // - -// The function returns an array object... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x ); // $ExpectType ArrayObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0c7d9c8..4c5f800 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..90532e6 --- /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 +/// +function t(t,e){return t[e]}function e(t,e){return t.get(e)}function n(t,e,n){t[e]=n}function r(t,e,n){t.set(n,e)}function o(o){var u=Boolean(o.get&&o.set);return{data:o,accessors:u,getter:u?e:t,setter:u?r:n}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..37e9e0e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;AA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCoBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,QAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/lib/getter.accessor.js b/lib/getter.accessor.js deleted file mode 100644 index aca5b1c..0000000 --- a/lib/getter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x.get( idx ); -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index 8a08c81..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x[ idx ]; -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 9099d34..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var getIndexed = require( './getter.js' ); -var getAccessor = require( './getter.accessor.js' ); -var setIndexed = require( './setter.js' ); -var setAccessor = require( './setter.accessor.js' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: data buffer. -* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements. -* - **getter**: accessor for retrieving a data buffer element. -* - **setter**: accessor for setting a data buffer element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance. - return { - 'data': x, - 'accessors': bool, - 'getter': ( bool ) ? getAccessor : getIndexed, - 'setter': ( bool ) ? setAccessor : setIndexed - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/lib/setter.accessor.js b/lib/setter.accessor.js deleted file mode 100644 index 60ba427..0000000 --- a/lib/setter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x.set( value, idx ); -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index b4bdd2a..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x[ idx ] = value; -} - - -// EXPORTS // - -module.exports = setter; diff --git a/package.json b/package.json index c3347f9..efe6ee4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,38 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^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", @@ -84,9 +29,8 @@ "utils", "util" ], - "__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..ceee789 --- /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 0bee513..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessors': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 39fd5e51a48402a0f7bd3247ae4251830bd776a4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 15:50:48 +0000 Subject: [PATCH 008/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3d8b66b..c3347f9 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.x", @@ -88,4 +89,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 0255e71c8527e2d634a20a819cf65ad9bbf13238 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 15:51:12 +0000 Subject: [PATCH 009/115] Remove files --- index.d.ts | 89 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2783 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 4c5f800..0000000 --- a/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/object'; - -/** -* Returns an array element. -* -* @param data - array data -* @param idx - element index -* @returns element value -*/ -type Getter = ( data: Collection, idx: number ) => any; - -/** -* Sets an array element. -* -* @param data - array data -* @param idx - element index -* @param value - value to set -*/ -type Setter = ( data: Collection, idx: number, value: any ) => void; - -/** -* Interface describing the output object. -*/ -interface ArrayObject { - /** - * Data buffer. - */ - data: Collection; - - /** - * Boolean indicating whether the data buffer uses accessors for getting and setting elements. - */ - accessors: boolean; - - /** - * Accessor for retrieving a data buffer element. - */ - getter: Getter; - - /** - * Accessor for setting a data buffer element. - */ - setter: Setter; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var obj = arraylike2object( x ); -* // returns {...} -*/ -declare function arraylike2object( x: Collection ): ArrayObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 90532e6..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 -/// -function t(t,e){return t[e]}function e(t,e){return t.get(e)}function n(t,e,n){t[e]=n}function r(t,e,n){t.set(n,e)}function o(o){var u=Boolean(o.get&&o.set);return{data:o,accessors:u,getter:u?e:t,setter:u?r:n}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 37e9e0e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;AA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCoBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,QAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ceee789..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From f1595584646467753321f1d0483b96e112b6b55d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 15:51:59 +0000 Subject: [PATCH 010/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 46 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/getter.accessor.js | 38 - lib/getter.js | 38 - lib/index.js | 40 - lib/main.js | 65 - lib/setter.accessor.js | 38 - lib/setter.js | 38 - package.json | 62 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 125 - 40 files changed, 2712 insertions(+), 3554 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 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/getter.accessor.js delete mode 100644 lib/getter.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/setter.accessor.js delete mode 100644 lib/setter.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 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -154,7 +147,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index bddbd7e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index f50d648..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: data buffer. - - accessors: boolean indicating whether the data buffer uses accessors for - getting and setting elements. - - getter: accessor for retrieving a data buffer element. - - setter: accessor for setting a data buffer element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5c5cf31..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arraylike2object = require( './index' ); - - -// TESTS // - -// The function returns an array object... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x ); // $ExpectType ArrayObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0c7d9c8..4c5f800 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..90532e6 --- /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 +/// +function t(t,e){return t[e]}function e(t,e){return t.get(e)}function n(t,e,n){t[e]=n}function r(t,e,n){t.set(n,e)}function o(o){var u=Boolean(o.get&&o.set);return{data:o,accessors:u,getter:u?e:t,setter:u?r:n}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..37e9e0e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;AA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCoBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,QAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/lib/getter.accessor.js b/lib/getter.accessor.js deleted file mode 100644 index aca5b1c..0000000 --- a/lib/getter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x.get( idx ); -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index 8a08c81..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x[ idx ]; -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 9099d34..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var getIndexed = require( './getter.js' ); -var getAccessor = require( './getter.accessor.js' ); -var setIndexed = require( './setter.js' ); -var setAccessor = require( './setter.accessor.js' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: data buffer. -* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements. -* - **getter**: accessor for retrieving a data buffer element. -* - **setter**: accessor for setting a data buffer element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance. - return { - 'data': x, - 'accessors': bool, - 'getter': ( bool ) ? getAccessor : getIndexed, - 'setter': ( bool ) ? setAccessor : setIndexed - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/lib/setter.accessor.js b/lib/setter.accessor.js deleted file mode 100644 index 60ba427..0000000 --- a/lib/setter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x.set( value, idx ); -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index b4bdd2a..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x[ idx ] = value; -} - - -// EXPORTS // - -module.exports = setter; diff --git a/package.json b/package.json index c3347f9..efe6ee4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,38 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^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", @@ -84,9 +29,8 @@ "utils", "util" ], - "__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..3770681 --- /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 0bee513..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessors': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 6f1fe8078873bd3b4a389a524f44c08aa073be54 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:56:41 +0000 Subject: [PATCH 011/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3d8b66b..c3347f9 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.x", @@ -88,4 +89,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From f99665ab619e9e677d78207d1ed3a3f0a3fa033e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:40:04 +0000 Subject: [PATCH 012/115] Remove files --- index.d.ts | 89 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2783 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 4c5f800..0000000 --- a/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/object'; - -/** -* Returns an array element. -* -* @param data - array data -* @param idx - element index -* @returns element value -*/ -type Getter = ( data: Collection, idx: number ) => any; - -/** -* Sets an array element. -* -* @param data - array data -* @param idx - element index -* @param value - value to set -*/ -type Setter = ( data: Collection, idx: number, value: any ) => void; - -/** -* Interface describing the output object. -*/ -interface ArrayObject { - /** - * Data buffer. - */ - data: Collection; - - /** - * Boolean indicating whether the data buffer uses accessors for getting and setting elements. - */ - accessors: boolean; - - /** - * Accessor for retrieving a data buffer element. - */ - getter: Getter; - - /** - * Accessor for setting a data buffer element. - */ - setter: Setter; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var obj = arraylike2object( x ); -* // returns {...} -*/ -declare function arraylike2object( x: Collection ): ArrayObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 90532e6..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 -/// -function t(t,e){return t[e]}function e(t,e){return t.get(e)}function n(t,e,n){t[e]=n}function r(t,e,n){t.set(n,e)}function o(o){var u=Boolean(o.get&&o.set);return{data:o,accessors:u,getter:u?e:t,setter:u?r:n}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 37e9e0e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;AA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCoBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,QAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3770681..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From d96cbf4473f653effd510907c0a96f79dbc440c9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:40:45 +0000 Subject: [PATCH 013/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 46 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/getter.accessor.js | 38 - lib/getter.js | 38 - lib/index.js | 40 - lib/main.js | 65 - lib/setter.accessor.js | 38 - lib/setter.js | 38 - package.json | 62 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 125 - 41 files changed, 2712 insertions(+), 3628 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 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/getter.accessor.js delete mode 100644 lib/getter.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/setter.accessor.js delete mode 100644 lib/setter.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 6aed494..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:42:43.626Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -154,7 +147,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index bddbd7e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index f50d648..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: data buffer. - - accessors: boolean indicating whether the data buffer uses accessors for - getting and setting elements. - - getter: accessor for retrieving a data buffer element. - - setter: accessor for setting a data buffer element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5c5cf31..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arraylike2object = require( './index' ); - - -// TESTS // - -// The function returns an array object... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x ); // $ExpectType ArrayObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0c7d9c8..4c5f800 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..90532e6 --- /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 +/// +function t(t,e){return t[e]}function e(t,e){return t.get(e)}function n(t,e,n){t[e]=n}function r(t,e,n){t.set(n,e)}function o(o){var u=Boolean(o.get&&o.set);return{data:o,accessors:u,getter:u?e:t,setter:u?r:n}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..37e9e0e --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;AA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCoBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,QAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/lib/getter.accessor.js b/lib/getter.accessor.js deleted file mode 100644 index aca5b1c..0000000 --- a/lib/getter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x.get( idx ); -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index 8a08c81..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x[ idx ]; -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 9099d34..0000000 --- a/lib/main.js +++ /dev/null @@ -1,65 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var getIndexed = require( './getter.js' ); -var getAccessor = require( './getter.accessor.js' ); -var setIndexed = require( './setter.js' ); -var setAccessor = require( './setter.accessor.js' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: data buffer. -* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements. -* - **getter**: accessor for retrieving a data buffer element. -* - **setter**: accessor for setting a data buffer element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance. - return { - 'data': x, - 'accessors': bool, - 'getter': ( bool ) ? getAccessor : getIndexed, - 'setter': ( bool ) ? setAccessor : setIndexed - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/lib/setter.accessor.js b/lib/setter.accessor.js deleted file mode 100644 index 60ba427..0000000 --- a/lib/setter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x.set( value, idx ); -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index b4bdd2a..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x[ idx ] = value; -} - - -// EXPORTS // - -module.exports = setter; diff --git a/package.json b/package.json index c3347f9..efe6ee4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,38 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^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", @@ -84,9 +29,8 @@ "utils", "util" ], - "__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..a52e8ee --- /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 0bee513..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessors': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From a611c084673f3d893e19f2c13c196e367c12f243 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 04:22:36 +0000 Subject: [PATCH 014/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 387e960..e9115cd 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.x", @@ -89,4 +90,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From ccec4b5ffdff81a5cd7926b76574c9b983b89938 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 18:39:25 +0000 Subject: [PATCH 015/115] Remove files --- index.d.ts | 89 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2783 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 4c5f800..0000000 --- a/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/object'; - -/** -* Returns an array element. -* -* @param data - array data -* @param idx - element index -* @returns element value -*/ -type Getter = ( data: Collection, idx: number ) => any; - -/** -* Sets an array element. -* -* @param data - array data -* @param idx - element index -* @param value - value to set -*/ -type Setter = ( data: Collection, idx: number, value: any ) => void; - -/** -* Interface describing the output object. -*/ -interface ArrayObject { - /** - * Data buffer. - */ - data: Collection; - - /** - * Boolean indicating whether the data buffer uses accessors for getting and setting elements. - */ - accessors: boolean; - - /** - * Accessor for retrieving a data buffer element. - */ - getter: Getter; - - /** - * Accessor for setting a data buffer element. - */ - setter: Setter; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var obj = arraylike2object( x ); -* // returns {...} -*/ -declare function arraylike2object( x: Collection ): ArrayObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 90532e6..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 -/// -function t(t,e){return t[e]}function e(t,e){return t.get(e)}function n(t,e,n){t[e]=n}function r(t,e,n){t.set(n,e)}function o(o){var u=Boolean(o.get&&o.set);return{data:o,accessors:u,getter:u?e:t,setter:u?r:n}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 37e9e0e..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;AA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCoBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,QAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a52e8ee..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 5659ee9085d4c8bc741de1aeffb38ba79b000919 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 18:40:08 +0000 Subject: [PATCH 016/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 46 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/getter.accessor.js | 38 - lib/getter.js | 38 - lib/index.js | 40 - lib/main.js | 66 - lib/setter.accessor.js | 38 - lib/setter.js | 38 - package.json | 63 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 125 - 41 files changed, 2712 insertions(+), 3646 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 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/getter.accessor.js delete mode 100644 lib/getter.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/setter.accessor.js delete mode 100644 lib/setter.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 f0a243f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:42:47.096Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -154,7 +147,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index bddbd7e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index f50d648..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: data buffer. - - accessors: boolean indicating whether the data buffer uses accessors for - getting and setting elements. - - getter: accessor for retrieving a data buffer element. - - setter: accessor for setting a data buffer element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5c5cf31..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arraylike2object = require( './index' ); - - -// TESTS // - -// The function returns an array object... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x ); // $ExpectType ArrayObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0c7d9c8..4c5f800 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2f04500 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";function e(t,e){return t[e]}function n(t,e){return t.get(e)}function r(t,e,n){t[e]=n}function s(t,e,n){t.set(n,e)}function o(o){var c=t(o.get&&o.set);return{data:o,accessors:c,getter:c?n:e,setter:c?s:r}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f9dc44d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 Boolean from '@stdlib/boolean-ctor' ;\nimport getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;uFA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCqBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,EAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/lib/getter.accessor.js b/lib/getter.accessor.js deleted file mode 100644 index aca5b1c..0000000 --- a/lib/getter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x.get( idx ); -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index 8a08c81..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x[ idx ]; -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 775ccf7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); -var getIndexed = require( './getter.js' ); -var getAccessor = require( './getter.accessor.js' ); -var setIndexed = require( './setter.js' ); -var setAccessor = require( './setter.accessor.js' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: data buffer. -* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements. -* - **getter**: accessor for retrieving a data buffer element. -* - **setter**: accessor for setting a data buffer element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance. - return { - 'data': x, - 'accessors': bool, - 'getter': ( bool ) ? getAccessor : getIndexed, - 'setter': ( bool ) ? setAccessor : setIndexed - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/lib/setter.accessor.js b/lib/setter.accessor.js deleted file mode 100644 index 60ba427..0000000 --- a/lib/setter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x.set( value, idx ); -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index b4bdd2a..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x[ idx ] = value; -} - - -// EXPORTS // - -module.exports = setter; diff --git a/package.json b/package.json index e9115cd..efe6ee4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^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", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..2072c93 --- /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 0bee513..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessors': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 67535e5ee6c4cd2c5904509641f54a79c1f799ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:30:13 +0000 Subject: [PATCH 017/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 387e960..e9115cd 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.x", @@ -89,4 +90,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 1eaa39acc3590559d8f90cda21629f658479e97e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 19:11:25 +0000 Subject: [PATCH 018/115] Remove files --- index.d.ts | 89 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2783 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 4c5f800..0000000 --- a/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/object'; - -/** -* Returns an array element. -* -* @param data - array data -* @param idx - element index -* @returns element value -*/ -type Getter = ( data: Collection, idx: number ) => any; - -/** -* Sets an array element. -* -* @param data - array data -* @param idx - element index -* @param value - value to set -*/ -type Setter = ( data: Collection, idx: number, value: any ) => void; - -/** -* Interface describing the output object. -*/ -interface ArrayObject { - /** - * Data buffer. - */ - data: Collection; - - /** - * Boolean indicating whether the data buffer uses accessors for getting and setting elements. - */ - accessors: boolean; - - /** - * Accessor for retrieving a data buffer element. - */ - getter: Getter; - - /** - * Accessor for setting a data buffer element. - */ - setter: Setter; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var obj = arraylike2object( x ); -* // returns {...} -*/ -declare function arraylike2object( x: Collection ): ArrayObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2f04500..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";function e(t,e){return t[e]}function n(t,e){return t.get(e)}function r(t,e,n){t[e]=n}function s(t,e,n){t.set(n,e)}function o(o){var c=t(o.get&&o.set);return{data:o,accessors:c,getter:c?n:e,setter:c?s:r}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f9dc44d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 Boolean from '@stdlib/boolean-ctor' ;\nimport getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;uFA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCqBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,EAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2072c93..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 94a3e5fe77aeedf23a504e9e27418e62fc8003ca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 19:12:04 +0000 Subject: [PATCH 019/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 46 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/getter.accessor.js | 38 - lib/getter.js | 38 - lib/index.js | 40 - lib/main.js | 66 - lib/setter.accessor.js | 38 - lib/setter.js | 38 - package.json | 63 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 125 - 41 files changed, 2712 insertions(+), 3646 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 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/getter.accessor.js delete mode 100644 lib/getter.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/setter.accessor.js delete mode 100644 lib/setter.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 c57323e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:10:18.629Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -154,7 +147,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index bddbd7e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index f50d648..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: data buffer. - - accessors: boolean indicating whether the data buffer uses accessors for - getting and setting elements. - - getter: accessor for retrieving a data buffer element. - - setter: accessor for setting a data buffer element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5c5cf31..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arraylike2object = require( './index' ); - - -// TESTS // - -// The function returns an array object... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x ); // $ExpectType ArrayObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0c7d9c8..4c5f800 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2f04500 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";function e(t,e){return t[e]}function n(t,e){return t.get(e)}function r(t,e,n){t[e]=n}function s(t,e,n){t.set(n,e)}function o(o){var c=t(o.get&&o.set);return{data:o,accessors:c,getter:c?n:e,setter:c?s:r}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..f9dc44d --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 Boolean from '@stdlib/boolean-ctor' ;\nimport getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;uFA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCqBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,EAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/lib/getter.accessor.js b/lib/getter.accessor.js deleted file mode 100644 index aca5b1c..0000000 --- a/lib/getter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x.get( idx ); -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index 8a08c81..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x[ idx ]; -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 775ccf7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); -var getIndexed = require( './getter.js' ); -var getAccessor = require( './getter.accessor.js' ); -var setIndexed = require( './setter.js' ); -var setAccessor = require( './setter.accessor.js' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: data buffer. -* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements. -* - **getter**: accessor for retrieving a data buffer element. -* - **setter**: accessor for setting a data buffer element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance. - return { - 'data': x, - 'accessors': bool, - 'getter': ( bool ) ? getAccessor : getIndexed, - 'setter': ( bool ) ? setAccessor : setIndexed - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/lib/setter.accessor.js b/lib/setter.accessor.js deleted file mode 100644 index 60ba427..0000000 --- a/lib/setter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x.set( value, idx ); -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index b4bdd2a..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x[ idx ] = value; -} - - -// EXPORTS // - -module.exports = setter; diff --git a/package.json b/package.json index e9115cd..efe6ee4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^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", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..edb9c86 --- /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 0bee513..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessors': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 172bd695f73784488925ce7f3536d68bd3dff2cb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:09:52 +0000 Subject: [PATCH 020/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 387e960..e9115cd 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.x", @@ -89,4 +90,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 7eb9f9e03e1930bf254a1997b4ed5c7033a6c9e9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:24:29 +0000 Subject: [PATCH 021/115] Remove files --- index.d.ts | 89 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2783 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 4c5f800..0000000 --- a/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/object'; - -/** -* Returns an array element. -* -* @param data - array data -* @param idx - element index -* @returns element value -*/ -type Getter = ( data: Collection, idx: number ) => any; - -/** -* Sets an array element. -* -* @param data - array data -* @param idx - element index -* @param value - value to set -*/ -type Setter = ( data: Collection, idx: number, value: any ) => void; - -/** -* Interface describing the output object. -*/ -interface ArrayObject { - /** - * Data buffer. - */ - data: Collection; - - /** - * Boolean indicating whether the data buffer uses accessors for getting and setting elements. - */ - accessors: boolean; - - /** - * Accessor for retrieving a data buffer element. - */ - getter: Getter; - - /** - * Accessor for setting a data buffer element. - */ - setter: Setter; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var obj = arraylike2object( x ); -* // returns {...} -*/ -declare function arraylike2object( x: Collection ): ArrayObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2f04500..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";function e(t,e){return t[e]}function n(t,e){return t.get(e)}function r(t,e,n){t[e]=n}function s(t,e,n){t.set(n,e)}function o(o){var c=t(o.get&&o.set);return{data:o,accessors:c,getter:c?n:e,setter:c?s:r}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index f9dc44d..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 Boolean from '@stdlib/boolean-ctor' ;\nimport getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;uFA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,GCDX,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,GCDf,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,ECDZ,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,GCqBf,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,EAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index edb9c86..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 08482022e7a66a04468f84ac95376a9a9048279e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 15:25:09 +0000 Subject: [PATCH 022/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 46 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/getter.accessor.js | 38 - lib/getter.js | 38 - lib/index.js | 40 - lib/main.js | 66 - lib/setter.accessor.js | 38 - lib/setter.js | 38 - package.json | 63 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 125 - 41 files changed, 4067 insertions(+), 3646 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 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/getter.accessor.js delete mode 100644 lib/getter.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/setter.accessor.js delete mode 100644 lib/setter.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 5e6df5d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:55:52.102Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d8083d1..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: '57 21 * * 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@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 + + ```
@@ -154,7 +147,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index bddbd7e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index f50d648..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: data buffer. - - accessors: boolean indicating whether the data buffer uses accessors for - getting and setting elements. - - getter: accessor for retrieving a data buffer element. - - setter: accessor for setting a data buffer element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5c5cf31..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arraylike2object = require( './index' ); - - -// TESTS // - -// The function returns an array object... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x ); // $ExpectType ArrayObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0c7d9c8..4c5f800 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2f04500 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";function e(t,e){return t[e]}function n(t,e){return t.get(e)}function r(t,e,n){t[e]=n}function s(t,e,n){t.set(n,e)}function o(o){var c=t(o.get&&o.set);return{data:o,accessors:c,getter:c?n:e,setter:c?s:r}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d2ef388 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 Boolean from '@stdlib/boolean-ctor' ;\nimport getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;uFA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,EACX,CCFA,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,EACf,CCFA,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,CACZ,CCFA,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,EACf,CCoBA,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,EAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC,EAErC"} \ No newline at end of file diff --git a/lib/getter.accessor.js b/lib/getter.accessor.js deleted file mode 100644 index aca5b1c..0000000 --- a/lib/getter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x.get( idx ); -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index 8a08c81..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x[ idx ]; -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 775ccf7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); -var getIndexed = require( './getter.js' ); -var getAccessor = require( './getter.accessor.js' ); -var setIndexed = require( './setter.js' ); -var setAccessor = require( './setter.accessor.js' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: data buffer. -* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements. -* - **getter**: accessor for retrieving a data buffer element. -* - **setter**: accessor for setting a data buffer element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance. - return { - 'data': x, - 'accessors': bool, - 'getter': ( bool ) ? getAccessor : getIndexed, - 'setter': ( bool ) ? setAccessor : setIndexed - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/lib/setter.accessor.js b/lib/setter.accessor.js deleted file mode 100644 index 60ba427..0000000 --- a/lib/setter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x.set( value, idx ); -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index b4bdd2a..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x[ idx ] = value; -} - - -// EXPORTS // - -module.exports = setter; diff --git a/package.json b/package.json index e9115cd..efe6ee4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^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", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..b0dbf0f --- /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 0bee513..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessors': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From fa1449922af1850becfdb9bf62c7dfa7e9428437 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:41:14 +0000 Subject: [PATCH 023/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 387e960..e9115cd 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.x", @@ -89,4 +90,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 042ec32b178104f751d5cfffa714cfbd36ed016b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 11:41:58 +0000 Subject: [PATCH 024/115] Remove files --- index.d.ts | 89 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4138 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 4c5f800..0000000 --- a/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/object'; - -/** -* Returns an array element. -* -* @param data - array data -* @param idx - element index -* @returns element value -*/ -type Getter = ( data: Collection, idx: number ) => any; - -/** -* Sets an array element. -* -* @param data - array data -* @param idx - element index -* @param value - value to set -*/ -type Setter = ( data: Collection, idx: number, value: any ) => void; - -/** -* Interface describing the output object. -*/ -interface ArrayObject { - /** - * Data buffer. - */ - data: Collection; - - /** - * Boolean indicating whether the data buffer uses accessors for getting and setting elements. - */ - accessors: boolean; - - /** - * Accessor for retrieving a data buffer element. - */ - getter: Getter; - - /** - * Accessor for setting a data buffer element. - */ - setter: Setter; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var obj = arraylike2object( x ); -* // returns {...} -*/ -declare function arraylike2object( x: Collection ): ArrayObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2f04500..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";function e(t,e){return t[e]}function n(t,e){return t.get(e)}function r(t,e,n){t[e]=n}function s(t,e,n){t.set(n,e)}function o(o){var c=t(o.get&&o.set);return{data:o,accessors:c,getter:c?n:e,setter:c?s:r}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d2ef388..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 Boolean from '@stdlib/boolean-ctor' ;\nimport getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;uFA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,EACX,CCFA,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,EACf,CCFA,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,CACZ,CCFA,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,EACf,CCoBA,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,EAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC,EAErC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b0dbf0f..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0a52ffeec09f9464d80e7ee69783543d6e88b2e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 11:42:43 +0000 Subject: [PATCH 025/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 46 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/getter.accessor.js | 38 - lib/getter.js | 38 - lib/index.js | 40 - lib/main.js | 66 - lib/setter.accessor.js | 38 - lib/setter.js | 38 - package.json | 63 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 125 - 41 files changed, 4067 insertions(+), 3667 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 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/getter.accessor.js delete mode 100644 lib/getter.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/setter.accessor.js delete mode 100644 lib/setter.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 a18726d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:56:42.009Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d8083d1..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: '57 21 * * 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@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 + + ```
@@ -154,7 +147,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index bddbd7e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index f50d648..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: data buffer. - - accessors: boolean indicating whether the data buffer uses accessors for - getting and setting elements. - - getter: accessor for retrieving a data buffer element. - - setter: accessor for setting a data buffer element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5c5cf31..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arraylike2object = require( './index' ); - - -// TESTS // - -// The function returns an array object... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x ); // $ExpectType ArrayObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0c7d9c8..4c5f800 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2f04500 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";function e(t,e){return t[e]}function n(t,e){return t.get(e)}function r(t,e,n){t[e]=n}function s(t,e,n){t.set(n,e)}function o(o){var c=t(o.get&&o.set);return{data:o,accessors:c,getter:c?n:e,setter:c?s:r}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..d2ef388 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 Boolean from '@stdlib/boolean-ctor' ;\nimport getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;uFA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,EACX,CCFA,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,EACf,CCFA,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,CACZ,CCFA,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,EACf,CCoBA,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,EAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC,EAErC"} \ No newline at end of file diff --git a/lib/getter.accessor.js b/lib/getter.accessor.js deleted file mode 100644 index aca5b1c..0000000 --- a/lib/getter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x.get( idx ); -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index 8a08c81..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x[ idx ]; -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 775ccf7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); -var getIndexed = require( './getter.js' ); -var getAccessor = require( './getter.accessor.js' ); -var setIndexed = require( './setter.js' ); -var setAccessor = require( './setter.accessor.js' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: data buffer. -* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements. -* - **getter**: accessor for retrieving a data buffer element. -* - **setter**: accessor for setting a data buffer element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance. - return { - 'data': x, - 'accessors': bool, - 'getter': ( bool ) ? getAccessor : getIndexed, - 'setter': ( bool ) ? setAccessor : setIndexed - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/lib/setter.accessor.js b/lib/setter.accessor.js deleted file mode 100644 index 60ba427..0000000 --- a/lib/setter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x.set( value, idx ); -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index b4bdd2a..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x[ idx ] = value; -} - - -// EXPORTS // - -module.exports = setter; diff --git a/package.json b/package.json index e9115cd..efe6ee4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^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", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..64fba9f --- /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 0bee513..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessors': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 29bb0e60f7915a00de708eac1fac298fab9d210d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 02:45:59 +0000 Subject: [PATCH 026/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b007d5e..8deaefa 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.x", @@ -89,4 +90,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 1d03143a9f4162442c6edd378ea94de0031668af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:43:23 +0000 Subject: [PATCH 027/115] Remove files --- index.d.ts | 89 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4138 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 4c5f800..0000000 --- a/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/object'; - -/** -* Returns an array element. -* -* @param data - array data -* @param idx - element index -* @returns element value -*/ -type Getter = ( data: Collection, idx: number ) => any; - -/** -* Sets an array element. -* -* @param data - array data -* @param idx - element index -* @param value - value to set -*/ -type Setter = ( data: Collection, idx: number, value: any ) => void; - -/** -* Interface describing the output object. -*/ -interface ArrayObject { - /** - * Data buffer. - */ - data: Collection; - - /** - * Boolean indicating whether the data buffer uses accessors for getting and setting elements. - */ - accessors: boolean; - - /** - * Accessor for retrieving a data buffer element. - */ - getter: Getter; - - /** - * Accessor for setting a data buffer element. - */ - setter: Setter; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var obj = arraylike2object( x ); -* // returns {...} -*/ -declare function arraylike2object( x: Collection ): ArrayObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2f04500..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";function e(t,e){return t[e]}function n(t,e){return t.get(e)}function r(t,e,n){t[e]=n}function s(t,e,n){t.set(n,e)}function o(o){var c=t(o.get&&o.set);return{data:o,accessors:c,getter:c?n:e,setter:c?s:r}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index d2ef388..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 Boolean from '@stdlib/boolean-ctor' ;\nimport getIndexed from './getter.js' ;\nimport getAccessor from './getter.accessor.js' ;\nimport setIndexed from './setter.js' ;\nimport setAccessor from './setter.accessor.js' ;\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;uFA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,EACX,CCFA,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,EACf,CCFA,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,CACZ,CCFA,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,EACf,CCoBA,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,EAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC,EAErC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 64fba9f..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e10750b91b2197ae14e302c652802fe923ebfd94 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:44:04 +0000 Subject: [PATCH 028/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 46 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/getter.accessor.js | 38 - lib/getter.js | 38 - lib/index.js | 40 - lib/main.js | 66 - lib/setter.accessor.js | 38 - lib/setter.js | 38 - package.json | 63 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 125 - 41 files changed, 4067 insertions(+), 3672 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 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/getter.accessor.js delete mode 100644 lib/getter.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/setter.accessor.js delete mode 100644 lib/setter.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 c046251..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:45:23.927Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d8083d1..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: '57 21 * * 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@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 + + ```
@@ -154,7 +147,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index bddbd7e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index f50d648..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: data buffer. - - accessors: boolean indicating whether the data buffer uses accessors for - getting and setting elements. - - getter: accessor for retrieving a data buffer element. - - setter: accessor for setting a data buffer element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5c5cf31..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 arraylike2object = require( './index' ); - - -// TESTS // - -// The function returns an array object... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x ); // $ExpectType ArrayObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0c7d9c8..4c5f800 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2f04500 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";function e(t,e){return t[e]}function n(t,e){return t.get(e)}function r(t,e,n){t[e]=n}function s(t,e,n){t.set(n,e)}function o(o){var c=t(o.get&&o.set);return{data:o,accessors:c,getter:c?n:e,setter:c?s:r}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a69dbf4 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 Boolean from '@stdlib/boolean-ctor';\nimport getIndexed from './getter.js';\nimport getAccessor from './getter.accessor.js';\nimport setIndexed from './setter.js';\nimport setAccessor from './setter.accessor.js';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;uFA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,EACX,CCFA,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,EACf,CCFA,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,CACZ,CCFA,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,EACf,CCoBA,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,EAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC,EAErC"} \ No newline at end of file diff --git a/lib/getter.accessor.js b/lib/getter.accessor.js deleted file mode 100644 index aca5b1c..0000000 --- a/lib/getter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x.get( idx ); -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/getter.js b/lib/getter.js deleted file mode 100644 index 8a08c81..0000000 --- a/lib/getter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Returns an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @returns {*} element -*/ -function getter( x, idx ) { - return x[ idx ]; -} - - -// EXPORTS // - -module.exports = getter; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 775ccf7..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var Boolean = require( '@stdlib/boolean-ctor' ); -var getIndexed = require( './getter.js' ); -var getAccessor = require( './getter.accessor.js' ); -var setIndexed = require( './setter.js' ); -var setAccessor = require( './setter.accessor.js' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: data buffer. -* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements. -* - **getter**: accessor for retrieving a data buffer element. -* - **setter**: accessor for setting a data buffer element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance. - return { - 'data': x, - 'accessors': bool, - 'getter': ( bool ) ? getAccessor : getIndexed, - 'setter': ( bool ) ? setAccessor : setIndexed - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/lib/setter.accessor.js b/lib/setter.accessor.js deleted file mode 100644 index 60ba427..0000000 --- a/lib/setter.accessor.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element using an accessor method. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x.set( value, idx ); -} - - -// EXPORTS // - -module.exports = setter; diff --git a/lib/setter.js b/lib/setter.js deleted file mode 100644 index b4bdd2a..0000000 --- a/lib/setter.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Sets an array element. -* -* @private -* @param {Collection} x - input array -* @param {NonNegativeInteger} idx - element index -* @param {*} value - value to set -*/ -function setter( x, idx, value ) { - x[ idx ] = value; -} - - -// EXPORTS // - -module.exports = setter; diff --git a/package.json b/package.json index 8deaefa..efe6ee4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/boolean-ctor": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^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", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..a480a8c --- /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 0bee513..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessors': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, 1.0 ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessors': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessors, expected.accessors, 'returns expected value' ); - t.strictEqual( typeof actual.getter, 'function', 'returns expected value' ); - t.strictEqual( actual.getter.length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.setter, 'function', 'returns expected value' ); - t.strictEqual( actual.setter.length, 3, 'returns expected value' ); - - actual.setter( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.getter( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 557ad0aa4554943cd07901671cceae13fd29dd76 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 04:07:19 +0000 Subject: [PATCH 029/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 28ac1ef..fd8e65e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/types": "^0.0.14" + "@stdlib/types": "^0.0.14", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.2", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9d67aeef0dac1d56cfa3c2ff3d39e56fcb0d9b8d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 04:07:51 +0000 Subject: [PATCH 030/115] Remove files --- index.d.ts | 89 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4138 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 4c5f800..0000000 --- a/index.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection } from '@stdlib/types/object'; - -/** -* Returns an array element. -* -* @param data - array data -* @param idx - element index -* @returns element value -*/ -type Getter = ( data: Collection, idx: number ) => any; - -/** -* Sets an array element. -* -* @param data - array data -* @param idx - element index -* @param value - value to set -*/ -type Setter = ( data: Collection, idx: number, value: any ) => void; - -/** -* Interface describing the output object. -*/ -interface ArrayObject { - /** - * Data buffer. - */ - data: Collection; - - /** - * Boolean indicating whether the data buffer uses accessors for getting and setting elements. - */ - accessors: boolean; - - /** - * Accessor for retrieving a data buffer element. - */ - getter: Getter; - - /** - * Accessor for setting a data buffer element. - */ - setter: Setter; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4, 5, 6 ]; -* -* var obj = arraylike2object( x ); -* // returns {...} -*/ -declare function arraylike2object( x: Collection ): ArrayObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2f04500..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/boolean-ctor@v0.0.1-esm/index.mjs";function e(t,e){return t[e]}function n(t,e){return t.get(e)}function r(t,e,n){t[e]=n}function s(t,e,n){t.set(n,e)}function o(o){var c=t(o.get&&o.set);return{data:o,accessors:c,getter:c?n:e,setter:c?s:r}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a69dbf4..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/getter.js","../lib/getter.accessor.js","../lib/setter.js","../lib/setter.accessor.js","../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x[ idx ];\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Returns an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @returns {*} element\n*/\nfunction getter( x, idx ) {\n\treturn x.get( idx );\n}\n\n\n// EXPORTS //\n\nexport default getter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx[ idx ] = value;\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Sets an array element using an accessor method.\n*\n* @private\n* @param {Collection} x - input array\n* @param {NonNegativeInteger} idx - element index\n* @param {*} value - value to set\n*/\nfunction setter( x, idx, value ) {\n\tx.set( value, idx );\n}\n\n\n// EXPORTS //\n\nexport default setter;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 Boolean from '@stdlib/boolean-ctor';\nimport getIndexed from './getter.js';\nimport getAccessor from './getter.accessor.js';\nimport setIndexed from './setter.js';\nimport setAccessor from './setter.accessor.js';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: data buffer.\n* - **accessors**: `boolean` indicating whether the data buffer uses accessors for getting and setting elements.\n* - **getter**: accessor for retrieving a data buffer element.\n* - **setter**: accessor for setting a data buffer element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar bool = Boolean( x.get && x.set ); // Note: intentional weak check, as we don't explicitly check for functions for (perhaps marginally) better performance.\n\treturn {\n\t\t'data': x,\n\t\t'accessors': bool,\n\t\t'getter': ( bool ) ? getAccessor : getIndexed,\n\t\t'setter': ( bool ) ? setAccessor : setIndexed\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["getter","x","idx","get","setter","value","set","arraylike2object","bool","Boolean","data","accessors","getAccessor","getIndexed","setAccessor","setIndexed"],"mappings":";;uFA8BA,SAASA,EAAQC,EAAGC,GACnB,OAAOD,EAAGC,EACX,CCFA,SAASF,EAAQC,EAAGC,GACnB,OAAOD,EAAEE,IAAKD,EACf,CCFA,SAASE,EAAQH,EAAGC,EAAKG,GACxBJ,EAAGC,GAAQG,CACZ,CCFA,SAASD,EAAQH,EAAGC,EAAKG,GACxBJ,EAAEK,IAAKD,EAAOH,EACf,CCoBA,SAASK,EAAkBN,GAC1B,IAAIO,EAAOC,EAASR,EAAEE,KAAOF,EAAEK,KAC/B,MAAO,CACNI,KAAQT,EACRU,UAAaH,EACbR,OAAU,EAAWY,EAAcC,EACnCT,OAAU,EAAWU,EAAcC,EAErC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a480a8c..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e02ed07ec6d840b5a1c2fba57f4e284ddcb716c8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 04:08:51 +0000 Subject: [PATCH 031/115] 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 | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 125 - 36 files changed, 6200 insertions(+), 3760 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 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d8083d1..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: '57 21 * * 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@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 + + ```
@@ -153,7 +146,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c834ad2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; // tslint:disable-line:no-unsafe-any - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 41a7a3f..fba8de6 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Collection, Complex64, Complex128, ComplexLike } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f2f9cf7 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index fd8e65e..7b465e7 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.2", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float32": "^0.0.7", - "@stdlib/complex-imagf": "^0.0.1", - "@stdlib/complex-realf": "^0.0.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" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..b8afe1b --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From e1a98391017d2247103d6e2cf7f3d1ea38360c70 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 00:11:21 +0000 Subject: [PATCH 032/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 28ac1ef..fd8e65e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/types": "^0.0.14" + "@stdlib/types": "^0.0.14", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.2", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 019c65bb665475fc20e16318e1d873c75a12db73 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 00:12:00 +0000 Subject: [PATCH 033/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 fba8de6..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Collection, Complex64, Complex128, ComplexLike } from '@stdlib/types/object'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f2f9cf7..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b8afe1b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 175f2c4a5696d22dcceb56638388bac727705b90 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 00:12:58 +0000 Subject: [PATCH 034/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 125 - 39 files changed, 6200 insertions(+), 3760 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/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 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d8083d1..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: '57 21 * * 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@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 + + ```
@@ -153,7 +146,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c834ad2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; // tslint:disable-line:no-unsafe-any - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index d0b21c8..e36d924 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f2f9cf7 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index fd8e65e..7b465e7 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.2", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float32": "^0.0.7", - "@stdlib/complex-imagf": "^0.0.1", - "@stdlib/complex-realf": "^0.0.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" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..1c3529c --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 6147f557822f2e1db9ca010208e122d3dc026eed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 02:18:51 +0000 Subject: [PATCH 035/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 28ac1ef..fd8e65e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/types": "^0.0.14" + "@stdlib/types": "^0.0.14", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.2", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a003cc349d3e1d71b80a3b1cc09bc5eee4a1a739 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 02:19:20 +0000 Subject: [PATCH 036/115] Remove files --- index.d.ts | 967 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7149 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 e36d924..0000000 --- a/index.d.ts +++ /dev/null @@ -1,967 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; -import { Collection } from '@stdlib/types/object'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f2f9cf7..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1c3529c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fc5685841f7b441612346c0b8e31cad98d20329b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 02:20:05 +0000 Subject: [PATCH 037/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 125 - 39 files changed, 6200 insertions(+), 3760 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/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 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d8083d1..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: '57 21 * * 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@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 + + ```
@@ -153,7 +146,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c834ad2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; // tslint:disable-line:no-unsafe-any - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 7450432..a3b42d9 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f2f9cf7 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index fd8e65e..7b465e7 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.2", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float32": "^0.0.7", - "@stdlib/complex-imagf": "^0.0.1", - "@stdlib/complex-realf": "^0.0.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" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..ff52a5c --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From e4f9f99b9282541ff5a649d35c688bee7f37a1fc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 01:30:32 +0000 Subject: [PATCH 038/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 28ac1ef..fd8e65e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/types": "^0.0.14" + "@stdlib/types": "^0.0.14", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.2", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 8cabf23e6664cfecc55597741ea3f2fc86fc956e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 01:31:47 +0000 Subject: [PATCH 039/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 a3b42d9..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f2f9cf7..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ff52a5c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b00c6994a57a1ed745bd8d352c090fd91f53fed2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 19 Aug 2023 01:32:40 +0000 Subject: [PATCH 040/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 125 - 39 files changed, 6200 insertions(+), 3760 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/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 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d8083d1..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: '57 21 * * 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@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 + + ```
@@ -153,7 +146,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c834ad2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; // tslint:disable-line:no-unsafe-any - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index ffa9e04..555ad8f 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f2f9cf7 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index fd8e65e..7b465e7 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.2", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float32": "^0.0.7", - "@stdlib/complex-imagf": "^0.0.1", - "@stdlib/complex-realf": "^0.0.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" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..f3833e1 --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 694c7a4a358f6975cbac02347d35e7dbbc98a8f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 24 Aug 2023 20:19:42 +0000 Subject: [PATCH 041/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 28ac1ef..fd8e65e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/types": "^0.0.14" + "@stdlib/types": "^0.0.14", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.0.2", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 28f2d0074a5cc07ef3edec08d27d8e3d3e5a7cff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 24 Aug 2023 20:23:07 +0000 Subject: [PATCH 042/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 555ad8f..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f2f9cf7..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f3833e1..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d04fa2e1e14e6f13882bb12c3d1d0e852380701 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 24 Aug 2023 20:23:56 +0000 Subject: [PATCH 043/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 125 - 39 files changed, 6200 insertions(+), 3760 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/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 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d8083d1..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: '57 21 * * 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@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 + + ```
@@ -153,7 +146,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c834ad2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; // tslint:disable-line:no-unsafe-any - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index fb47ad3..698e710 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f2f9cf7 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index fd8e65e..7b465e7 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.2", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.0.2", - "@stdlib/types": "^0.0.14", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.0.2", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float32": "^0.0.7", - "@stdlib/complex-imagf": "^0.0.1", - "@stdlib/complex-realf": "^0.0.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" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..e6e925c --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From dc25329c3cb166fbaf8c8cf4f03f4e260cb1cc4f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:36:57 +0000 Subject: [PATCH 044/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3209f25..4ba837d 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.1.0", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 879860a026a807e06b02d867260704ffbc9b0e13 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:00:37 +0000 Subject: [PATCH 045/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 698e710..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f2f9cf7..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e6e925c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d5d7b12d38e0903a35a5a793b080576326072743 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:01:21 +0000 Subject: [PATCH 046/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 125 - 40 files changed, 6200 insertions(+), 3795 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/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 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 becf251..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d8083d1..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: '57 21 * * 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@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 + + ```
@@ -164,7 +157,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c834ad2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; // tslint:disable-line:no-unsafe-any - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index fb47ad3..698e710 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f2f9cf7 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.0.2-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 4ba837d..b400605 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^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", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..82958e7 --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 4f4d37b7386cb78dcb40f7db376b6528350ace4c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:14:07 +0000 Subject: [PATCH 047/115] 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 b0a7968..8fd0958 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import arraylike2object from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs'; +import arraylike2object from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.1.0-esm/index.mjs'; ``` #### arraylike2object( x ) @@ -112,7 +112,7 @@ var obj = arraylike2object( [ 1, 2, 3, 4 ] ); - - - - From 6e454fb083d35b171d865336b93e2e6da0d5ad89 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:58:32 +0000 Subject: [PATCH 051/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 125 - test/test.js | 125 - 42 files changed, 6200 insertions(+), 3979 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 e57b71b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:36:49.901Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 526c9f7..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: '57 21 * * 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' - # 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 + + ```
@@ -164,7 +157,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c834ad2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; // tslint:disable-line:no-unsafe-any - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index fb47ad3..698e710 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..948b2a0 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index fb1292b..b400605 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.1.1", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^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", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..be68eae --- /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 c552bdb..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 358d6c70cf54ed9b148a097093bcc3a700f58313 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 20:24:47 +0000 Subject: [PATCH 052/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8aa98ff..c1cd378 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.1.1", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 41ae5fd826fbccf71eda547a71c57e5d7f98ade4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:59:59 +0000 Subject: [PATCH 053/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 698e710..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 948b2a0..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index be68eae..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From de85ceedab8c09831d8daf5a6721091b90d3ed24 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 04:00:47 +0000 Subject: [PATCH 054/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 125 - test/test.js | 125 - 41 files changed, 6200 insertions(+), 3978 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 526c9f7..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: '57 21 * * 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' - # 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 + + ```
@@ -164,7 +157,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c834ad2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; // tslint:disable-line:no-unsafe-any - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index fb47ad3..698e710 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..948b2a0 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index c1cd378..b400605 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.1.1", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^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", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..acc5838 --- /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 c552bdb..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 4543b9a10a6beb70b5269c39542dbac35d6340f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 18:09:16 +0000 Subject: [PATCH 055/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d469f1e..f86472c 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.1.1", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9fef9f67ba6903a13c4f7d597ecb3c717f31fa8b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 03:04:03 +0000 Subject: [PATCH 056/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 698e710..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 948b2a0..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index acc5838..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0e6ab46a5770bb5cf570a8c6e738458dab921c63 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 03:04:58 +0000 Subject: [PATCH 057/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 125 - 42 files changed, 6200 insertions(+), 3895 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 4385f5e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:58:11.459Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 526c9f7..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: '57 21 * * 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' - # 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 + + ```
@@ -164,7 +157,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c834ad2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; // tslint:disable-line:no-unsafe-any - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index fb47ad3..698e710 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..948b2a0 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index f86472c..b400605 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.1.1", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.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" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..de2b1e7 --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 26a0a2a295fe6b064e9e2d67bb1851c6e514166c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 12:47:48 +0000 Subject: [PATCH 058/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d469f1e..f86472c 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.1.1", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3ba23ba21663f02c624e77f7901212bc8cf1976e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 17:33:47 +0000 Subject: [PATCH 059/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 698e710..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; // tslint:disable-line:max-line-length - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; // tslint:disable-line:max-line-length - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 948b2a0..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index de2b1e7..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2f4e2f6434b06b8a85bee60f29768ad6ab039b60 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 17:34:38 +0000 Subject: [PATCH 060/115] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 125 - 41 files changed, 6200 insertions(+), 3894 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 526c9f7..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: '57 21 * * 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' - # 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 + + ```
@@ -164,7 +157,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index c834ad2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; // tslint:disable-line:no-unsafe-any - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 80747da..13c5227 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..948b2a0 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index f86472c..b400605 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.1.1", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.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" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..f3ac917 --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 1b1a3011507de82189234ef9a795f200ddda9f10 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:21:27 +0000 Subject: [PATCH 061/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 602b0af..48ad2a7 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.1.1", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 106b7bf60b44a21f28bd844637011d6fbeea2fda Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:22:44 +0000 Subject: [PATCH 062/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 13c5227..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 948b2a0..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f3ac917..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0ee271c266b40599f0ab030d8d2e3ec7291a7c02 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 12 Nov 2023 21:23:27 +0000 Subject: [PATCH 063/115] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 125 - 41 files changed, 6200 insertions(+), 3894 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 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 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 526c9f7..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: '57 21 * * 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' - # 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 + + ```
@@ -164,7 +157,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 80747da..13c5227 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..948b2a0 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 48ad2a7..b400605 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.1.1", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/bench": "^0.2.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.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" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..0dec427 --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 71fa7a1e4ffd66d8392a0844c403796f5357c1e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 14:18:59 +0000 Subject: [PATCH 064/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 20e5955..75d68d6 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.1.1", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9223f42706e9de263eb3898a7d1a97f7033bc498 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:44:36 +0000 Subject: [PATCH 065/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 13c5227..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 948b2a0..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0dec427..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 83701f42102c755554128376764eb5641bed55fa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:45:22 +0000 Subject: [PATCH 066/115] 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 | 35 +- benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 125 - 42 files changed, 6200 insertions(+), 3890 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 55d68bf..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T06:03:21.082Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 526c9f7..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: '57 21 * * 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' - # 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 + + ```
@@ -164,7 +157,7 @@ console.log( obj ); ## 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 76d39cc..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 80747da..13c5227 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..948b2a0 --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 75d68d6..b400605 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.1.1", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.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" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..d90d26e --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From c4275b36b2e17a4ef9539f9c7b4967a3d5cf1cc6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:35:52 +0000 Subject: [PATCH 067/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fa451fc..371130c 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.1.1", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f2f09dfd184cde9bee2f7eadf1743a2febcf8d64 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:15:38 +0000 Subject: [PATCH 068/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 13c5227..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 948b2a0..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d90d26e..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From abdc675ae3d9122fd3eeb6c0b10af64f46980e62 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:16:02 +0000 Subject: [PATCH 069/115] 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 | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 125 - 43 files changed, 6200 insertions(+), 3896 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 266b844..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:33:10.664Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d75a1ad..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: '57 21 * * 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' - # 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 + + ```
@@ -164,7 +157,7 @@ console.log( obj ); ## 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 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 80747da..13c5227 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8c7343a --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 371130c..b400605 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.1.1", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.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.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..dd0c222 --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From f656ca0675089d61442c47c15e10454cf8713ed7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:04:37 +0000 Subject: [PATCH 070/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fa451fc..371130c 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.1.1", @@ -89,4 +90,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9e04375188b4c83331a78fb8bf03fc0af90b5435 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:15:30 +0000 Subject: [PATCH 071/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 13c5227..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( `@stdlib/array/float32` ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( `@stdlib/array/int32` ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( `@stdlib/array/int16` ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( `@stdlib/array/int8` ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( `@stdlib/array/uint32` ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( `@stdlib/array/uint16` ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( `@stdlib/array/uint8` ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( `@stdlib/array/uint8c` ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( `@stdlib/array/complex128` ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( `@stdlib/array/complex64` ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8c7343a..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index dd0c222..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ad46ec1ad644fbcef1b22d7fc8b74efe9933c229 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:15:51 +0000 Subject: [PATCH 072/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 54 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 60 - package.json | 63 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 125 - 42 files changed, 6200 insertions(+), 3895 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d75a1ad..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: '57 21 * * 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' - # 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 + + ```
@@ -164,7 +157,7 @@ console.log( obj ); ## 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 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2566bf9..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 7e4bfe9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var o=function(s,r){return function(){return r||s((r={exports:{}}).exports,r),r.exports}};var e=o(function(n,c){ -var a=require('@stdlib/array-base-accessors/dist');function t(s){var r=a(s);return{data:s,accessorProtocol:r.accessorProtocol,accessors:r.accessors}}c.exports=t -});var i=e();module.exports=i; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 1a8465e..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors = require( '@stdlib/array-base-accessors' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAY,QAAS,8BAA+B,EAyBxD,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAIH,EAAWE,CAAE,EACrB,MAAO,CACN,KAAQA,EACR,iBAAoBC,EAAE,iBACtB,UAAaA,EAAE,SAChB,CACD,CAKAJ,EAAO,QAAUE,ICzBjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "accessors", "arraylike2object", "x", "o", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e5135be..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,54 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index b9943b8..f0379a7 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8c7343a --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e89a079 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a41ff12..0000000 --- a/lib/main.js +++ /dev/null @@ -1,60 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var accessors = require( '@stdlib/array-base-accessors' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var o = accessors( x ); - return { - 'data': x, - 'accessorProtocol': o.accessorProtocol, - 'accessors': o.accessors - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 371130c..b400605 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,39 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.1.0", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.1.1", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.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.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -85,9 +29,8 @@ "utils", "util" ], - "__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..0e15b65 --- /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 64a27b5..0000000 --- a/test/test.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 37fad026e35e2bc016ee9ba8ec786f686dceb540 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 6 Feb 2024 02:50:18 +0000 Subject: [PATCH 073/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f4c1d06..8b184b7 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/array-base-getter": "^0.1.0", "@stdlib/array-base-setter": "^0.1.0", "@stdlib/array-dtype": "^0.1.0", - "@stdlib/types": "^0.3.1" + "@stdlib/types": "^0.3.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.1.1", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ac488554722691d154710d6f4797904dce4aec46 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 6 Feb 2024 02:50:44 +0000 Subject: [PATCH 074/115] Remove files --- index.d.ts | 966 -------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7148 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 f0379a7..0000000 --- a/index.d.ts +++ /dev/null @@ -1,966 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array-float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array-int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array-int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array-int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array-uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array-uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array-complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8c7343a..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.1.0-esm/index.mjs";function r(r){var o=s(r);return{data:r,accessorProtocol:o.accessorProtocol,accessors:o.accessors}}export{r as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e89a079..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 accessors from '@stdlib/array-base-accessors';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar o = accessors( x );\n\treturn {\n\t\t'data': x,\n\t\t'accessorProtocol': o.accessorProtocol,\n\t\t'accessors': o.accessors\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","o","accessors","data","accessorProtocol"],"mappings":";;+FA+CA,SAASA,EAAkBC,GAC1B,IAAIC,EAAIC,EAAWF,GACnB,MAAO,CACNG,KAAQH,EACRI,iBAAoBH,EAAEG,iBACtBF,UAAaD,EAAEC,UAEjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0e15b65..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3175b7c641bd7be60754975ba5f9600ee0b22940 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 6 Feb 2024 02:51:13 +0000 Subject: [PATCH 075/115] 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 | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 42 files changed, 6201 insertions(+), 3941 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 77a2bef..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/stdlib +[@stdlib/array/dtype]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index eae1d4f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 64ac428..0e9d91b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bc053ac --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 8b184b7..b400605 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.1.0", - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-getter": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/types": "^0.3.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.1.1", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.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.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 +29,8 @@ "utils", "util" ], - "__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..a14eee7 --- /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 7f4f030..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From d846d39ce7159e275da33771a32bdb2d3ce086e9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 7 Feb 2024 02:25:47 +0000 Subject: [PATCH 076/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f4c1d06..8b184b7 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/array-base-getter": "^0.1.0", "@stdlib/array-base-setter": "^0.1.0", "@stdlib/array-dtype": "^0.1.0", - "@stdlib/types": "^0.3.1" + "@stdlib/types": "^0.3.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.1.1", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7e55d85d9b4bfd730defb41032d8e039b65182ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 7 Feb 2024 02:26:15 +0000 Subject: [PATCH 077/115] Remove files --- index.d.ts | 1038 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7220 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 0e9d91b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1038 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Data type. - */ - dtype: 'float64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Data type. - */ - dtype: 'float32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Data type. - */ - dtype: 'int32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Data type. - */ - dtype: 'int16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Data type. - */ - dtype: 'int8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Data type. - */ - dtype: 'uint32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Data type. - */ - dtype: 'uint16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Data type. - */ - dtype: 'uint8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Data type. - */ - dtype: 'uint8c'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Data type. - */ - dtype: 'complex128'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Data type. - */ - dtype: 'complex64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Data type. - */ - dtype: 'generic'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array-float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array-int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array-int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array-int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array-uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array-uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array-complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bc053ac..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e96b9a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a14eee7..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cda0f8566ea8d3898d09d3d1e4aa560c5fb18e20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 7 Feb 2024 02:26:34 +0000 Subject: [PATCH 078/115] 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 | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 42 files changed, 6201 insertions(+), 3941 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 77a2bef..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index eae1d4f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 64ac428..0e9d91b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bc053ac --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 8b184b7..b400605 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.1.0", - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-getter": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/types": "^0.3.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.1.1", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.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.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 +29,8 @@ "utils", "util" ], - "__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..29853d4 --- /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 7f4f030..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From d4d3739ac4d1a17b25e1a7021d54e2494d8b013f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 01:22:56 +0000 Subject: [PATCH 079/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6715a3b..2d46e18 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/array-base-getter": "^0.2.0", "@stdlib/array-base-setter": "^0.2.0", "@stdlib/array-dtype": "^0.2.0", - "@stdlib/types": "^0.3.1" + "@stdlib/types": "^0.3.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.2.0", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c24e9878c6782b0d24b76ed73946ac5915d5972e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:52:14 +0000 Subject: [PATCH 080/115] Remove files --- index.d.ts | 1038 --------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 7220 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 0e9d91b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1038 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Data type. - */ - dtype: 'float64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Data type. - */ - dtype: 'float32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Data type. - */ - dtype: 'int32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Data type. - */ - dtype: 'int16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Data type. - */ - dtype: 'int8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Data type. - */ - dtype: 'uint32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Data type. - */ - dtype: 'uint16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Data type. - */ - dtype: 'uint8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Data type. - */ - dtype: 'uint8c'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Data type. - */ - dtype: 'complex128'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Data type. - */ - dtype: 'complex64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Data type. - */ - dtype: 'generic'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array-float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array-int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array-int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array-int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array-uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array-uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array-complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bc053ac..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e96b9a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 29853d4..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 141f2f7a215f743cf9224a3a9781dbd37858a7bf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:52:32 +0000 Subject: [PATCH 081/115] 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 | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 42 files changed, 6201 insertions(+), 3941 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 77a2bef..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index eae1d4f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 64ac428..0e9d91b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..153158a --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 2d46e18..231e3c4 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.0", - "@stdlib/array-base-accessor-setter": "^0.2.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.0", - "@stdlib/array-base-getter": "^0.2.0", - "@stdlib/array-base-setter": "^0.2.0", - "@stdlib/array-dtype": "^0.2.0", - "@stdlib/types": "^0.3.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.2.0", - "@stdlib/assert-is-collection": "^0.2.0", - "@stdlib/complex-float32": "^0.2.0", - "@stdlib/complex-imagf": "^0.2.0", - "@stdlib/complex-realf": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -90,9 +29,8 @@ "utils", "util" ], - "__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..23cce18 --- /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 7f4f030..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From ff755fe665b990a7d0faa348698a6573b554e1d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:38:05 +0000 Subject: [PATCH 082/115] 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 ae108e4..c5c6df3 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import arraylike2object from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs'; +import arraylike2object from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.0-esm/index.mjs'; ``` #### arraylike2object( x ) @@ -113,7 +113,7 @@ var obj = arraylike2object( [ 1, 2, 3, 4 ] ); - - - - From 13f2edf80bc7f9dcb426d9b8a0ae67d0a970c444 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:23:36 +0000 Subject: [PATCH 086/115] 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 | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 42 files changed, 4866 insertions(+), 3935 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5cb4739..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index eae1d4f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 64ac428..0e9d91b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ee03fd --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 40b64c3..3bf1120 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.1", - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-getter": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.1", - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^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 +29,8 @@ "utils", "util" ], - "__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..b923a68 --- /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 7f4f030..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 56801698b63ec0bf6fb0635a479f4a8fac983a12 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:02:28 +0000 Subject: [PATCH 087/115] 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 c64b82f..3f33bfc 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import arraylike2object from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs'; +import arraylike2object from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@v0.2.1-esm/index.mjs'; ``` #### arraylike2object( x ) @@ -113,7 +113,7 @@ var obj = arraylike2object( [ 1, 2, 3, 4 ] ); - - - - From c6549e8d4e7c0d05d33610eb4621ed8b4fe2bfdb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:10:11 +0000 Subject: [PATCH 091/115] 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 | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 43 files changed, 4866 insertions(+), 3937 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 127b111..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T06:06:01.446Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5cb4739..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index eae1d4f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 64ac428..0e9d91b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ee03fd --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 49e32da..3bf1120 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.1", - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-getter": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^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 +29,8 @@ "utils", "util" ], - "__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..b923a68 --- /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 7f4f030..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 91b14ed3fbf4f7787db276f1ba316e1ae7363d21 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:43:42 +0000 Subject: [PATCH 092/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4d4dbcb..49e32da 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/array-base-getter": "^0.2.1", "@stdlib/array-base-setter": "^0.2.1", "@stdlib/array-dtype": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.2.1", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2ee2ce9b7c5f24ff76d87dab6f3890f74435a646 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:12:11 +0000 Subject: [PATCH 093/115] Remove files --- index.d.ts | 1038 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5885 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 0e9d91b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1038 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Data type. - */ - dtype: 'float64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Data type. - */ - dtype: 'float32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Data type. - */ - dtype: 'int32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Data type. - */ - dtype: 'int16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Data type. - */ - dtype: 'int8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Data type. - */ - dtype: 'uint32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Data type. - */ - dtype: 'uint16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Data type. - */ - dtype: 'uint8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Data type. - */ - dtype: 'uint8c'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Data type. - */ - dtype: 'complex128'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Data type. - */ - dtype: 'complex64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Data type. - */ - dtype: 'generic'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array-float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array-int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array-int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array-int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array-uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array-uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array-complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3ee03fd..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e96b9a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b923a68..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a96fb4b818654484b6d2dc7c695bea4fdf7e3a13 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:12:22 +0000 Subject: [PATCH 094/115] 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 | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 43 files changed, 4866 insertions(+), 3940 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0b20fca..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:21:52.160Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5cb4739..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index eae1d4f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 64ac428..0e9d91b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ee03fd --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 49e32da..3bf1120 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.1", - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-getter": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^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 +29,8 @@ "utils", "util" ], - "__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..b923a68 --- /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 7f4f030..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 7ba2268104b7f9e7c938aced6cf05dafedd9a6d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:57:10 +0000 Subject: [PATCH 095/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4d4dbcb..49e32da 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/array-base-getter": "^0.2.1", "@stdlib/array-base-setter": "^0.2.1", "@stdlib/array-dtype": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.2.1", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 51030fc7585745bf1f23816ecbdbe5b7f011d697 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:27:32 +0000 Subject: [PATCH 096/115] Remove files --- index.d.ts | 1038 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5885 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 0e9d91b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1038 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Data type. - */ - dtype: 'float64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Data type. - */ - dtype: 'float32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Data type. - */ - dtype: 'int32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Data type. - */ - dtype: 'int16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Data type. - */ - dtype: 'int8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Data type. - */ - dtype: 'uint32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Data type. - */ - dtype: 'uint16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Data type. - */ - dtype: 'uint8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Data type. - */ - dtype: 'uint8c'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Data type. - */ - dtype: 'complex128'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Data type. - */ - dtype: 'complex64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Data type. - */ - dtype: 'generic'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array-float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array-int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array-int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array-int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array-uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array-uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array-complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3ee03fd..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e96b9a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b923a68..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 98086441c54fc39ad2987b4bec7b6b4afb5dfaae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:27:49 +0000 Subject: [PATCH 097/115] 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 | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 42 files changed, 4866 insertions(+), 3941 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5cb4739..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index eae1d4f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 64ac428..0e9d91b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ee03fd --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 49e32da..3bf1120 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.1", - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-getter": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^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 +29,8 @@ "utils", "util" ], - "__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..b923a68 --- /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 7f4f030..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 5b303d16e3e3d427584ea21b736ec5ec1bdd38d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 08:52:04 +0000 Subject: [PATCH 098/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 257d1ea..51ac1ca 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/array-base-getter": "^0.2.1", "@stdlib/array-base-setter": "^0.2.1", "@stdlib/array-dtype": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.2.1", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f5895130a1502ee043b97c9e7643dc8328a6ecdd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 08:55:59 +0000 Subject: [PATCH 099/115] Remove files --- index.d.ts | 1038 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5885 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 0e9d91b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1038 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Data type. - */ - dtype: 'float64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Data type. - */ - dtype: 'float32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Data type. - */ - dtype: 'int32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Data type. - */ - dtype: 'int16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Data type. - */ - dtype: 'int8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Data type. - */ - dtype: 'uint32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Data type. - */ - dtype: 'uint16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Data type. - */ - dtype: 'uint8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Data type. - */ - dtype: 'uint8c'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Data type. - */ - dtype: 'complex128'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Data type. - */ - dtype: 'complex64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Data type. - */ - dtype: 'generic'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array-float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array-int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array-int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array-int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array-uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array-uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array-complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3ee03fd..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e96b9a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b923a68..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f01a6bf6aaba6919a944ade672c596664af2491e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 08:56:15 +0000 Subject: [PATCH 100/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 42 files changed, 4866 insertions(+), 3948 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5cb4739..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: '57 21 * * 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' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index eae1d4f..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array use accessors for getting and - setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 64ac428..0e9d91b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3ee03fd --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 51ac1ca..3bf1120 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.1", - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-getter": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/complex-float32-ctor": "github:stdlib-js/complex-float32-ctor#main", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^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 +29,8 @@ "utils", "util" ], - "__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..b923a68 --- /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 d33a896..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 6ebbef529753a9483e401b6eb9ed81eea306d456 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 15 Sep 2024 23:20:15 +0000 Subject: [PATCH 101/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e7b8a89..80bcb8b 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/array-base-getter": "^0.2.2", "@stdlib/array-base-setter": "^0.2.2", "@stdlib/array-dtype": "^0.3.0", - "@stdlib/types": "^0.4.1" + "@stdlib/types": "^0.4.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.2.2", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f1d11df858b94e4058aa8f522018217890502b40 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 15 Sep 2024 23:20:40 +0000 Subject: [PATCH 102/115] Remove files --- index.d.ts | 1038 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5885 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 0e9d91b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1038 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Data type. - */ - dtype: 'float64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Data type. - */ - dtype: 'float32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Data type. - */ - dtype: 'int32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Data type. - */ - dtype: 'int16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Data type. - */ - dtype: 'int8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Data type. - */ - dtype: 'uint32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Data type. - */ - dtype: 'uint16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Data type. - */ - dtype: 'uint8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Data type. - */ - dtype: 'uint8c'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Data type. - */ - dtype: 'complex128'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Data type. - */ - dtype: 'complex64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Data type. - */ - dtype: 'generic'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array-float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array-int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array-int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array-int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array-uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array-uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array-complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3ee03fd..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.1-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e96b9a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b923a68..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 445b40a09c76b2957935df75015ea3699a253a90 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 15 Sep 2024 23:20:56 +0000 Subject: [PATCH 103/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 196 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 42 files changed, 4866 insertions(+), 4145 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5cb4739..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 39828bf..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array uses accessors for getting - and setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 64ac428..0e9d91b 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fdb3d5a --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 80bcb8b..3bf1120 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.2", - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-getter": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.2", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.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 +29,8 @@ "utils", "util" ], - "__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..cb7ed8f --- /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 6e41a3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 016383d19240a6593a02bd9e4269390f761e2406 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 18 Sep 2024 06:59:35 +0000 Subject: [PATCH 104/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e7b8a89..80bcb8b 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/array-base-getter": "^0.2.2", "@stdlib/array-base-setter": "^0.2.2", "@stdlib/array-dtype": "^0.3.0", - "@stdlib/types": "^0.4.1" + "@stdlib/types": "^0.4.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.2.2", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9542ed0d429953388105b0b2048b3904d639a79d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 18 Sep 2024 06:59:59 +0000 Subject: [PATCH 105/115] Remove files --- index.d.ts | 1038 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5885 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 0e9d91b..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1038 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param -arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Data type. - */ - dtype: 'float64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Data type. - */ - dtype: 'float32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Data type. - */ - dtype: 'int32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Data type. - */ - dtype: 'int16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Data type. - */ - dtype: 'int8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Data type. - */ - dtype: 'uint32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Data type. - */ - dtype: 'uint16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Data type. - */ - dtype: 'uint8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Data type. - */ - dtype: 'uint8c'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Data type. - */ - dtype: 'complex128'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Data type. - */ - dtype: 'complex64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Data type. - */ - dtype: 'generic'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array-float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array-int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array-int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array-int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array-uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array-uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array-complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fdb3d5a..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e96b9a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cb7ed8f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e59c7d9b0d271dded6cd58476286ce4731eb946a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 18 Sep 2024 07:00:17 +0000 Subject: [PATCH 106/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 197 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 42 files changed, 4866 insertions(+), 4146 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5cb4739..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 39828bf..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array uses accessors for getting - and setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 4b64246..63021bf 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fdb3d5a --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 80bcb8b..3bf1120 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.2", - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-getter": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.2", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.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 +29,8 @@ "utils", "util" ], - "__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..cb7ed8f --- /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 6e41a3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 3f84dd3683ab87e42440b15f6c41098ac6cb841a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 18:01:36 +0000 Subject: [PATCH 107/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e7b8a89..80bcb8b 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/array-base-getter": "^0.2.2", "@stdlib/array-base-setter": "^0.2.2", "@stdlib/array-dtype": "^0.3.0", - "@stdlib/types": "^0.4.1" + "@stdlib/types": "^0.4.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.2.2", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1b960fae0d967aa000db4f222ea2d63a9ffb0ba7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 18:02:15 +0000 Subject: [PATCH 108/115] Remove files --- index.d.ts | 1037 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5884 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 63021bf..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1037 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Data type. - */ - dtype: 'float64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Data type. - */ - dtype: 'float32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Data type. - */ - dtype: 'int32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Data type. - */ - dtype: 'int16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Data type. - */ - dtype: 'int8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Data type. - */ - dtype: 'uint32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Data type. - */ - dtype: 'uint16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Data type. - */ - dtype: 'uint8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Data type. - */ - dtype: 'uint8c'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Data type. - */ - dtype: 'complex128'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Data type. - */ - dtype: 'complex64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Data type. - */ - dtype: 'generic'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array-float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array-int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array-int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array-int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array-uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array-uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array-complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 - }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fdb3d5a..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e96b9a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cb7ed8f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4ac2ba81d21eadc5e8f8d1476410658caaf7db1a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 18:02:29 +0000 Subject: [PATCH 109/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 199 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 128 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 42 files changed, 4866 insertions(+), 4148 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5cb4739..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 39828bf..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array uses accessors for getting - and setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index cb9630e..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,128 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @return array-like object -*/ -function accessorArray(): AccessorArrayLike { - let arr: AccessorArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @return array-like object -*/ -function arrayLike(): ArrayLike { - let arr: ArrayLike; - arr = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 6dffd28..3a135f7 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fdb3d5a --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 80bcb8b..3bf1120 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.2", - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-getter": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.2", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.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 +29,8 @@ "utils", "util" ], - "__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..cb7ed8f --- /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 6e41a3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 812784ec4da8c1f354bf8bb23d7f8c586361323c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:10:34 +0000 Subject: [PATCH 110/115] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e7b8a89..80bcb8b 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/array-base-getter": "^0.2.2", "@stdlib/array-base-setter": "^0.2.2", "@stdlib/array-dtype": "^0.3.0", - "@stdlib/types": "^0.4.1" + "@stdlib/types": "^0.4.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-zeros": "^0.2.2", @@ -94,4 +95,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f221c57cedf5d31388b02efd30ebc75827b3e500 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:11:01 +0000 Subject: [PATCH 111/115] Remove files --- index.d.ts | 1037 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5884 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 3a135f7..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1037 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Data type. - */ - dtype: 'float64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Data type. - */ - dtype: 'float32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Data type. - */ - dtype: 'int32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Data type. - */ - dtype: 'int16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Data type. - */ - dtype: 'int8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Data type. - */ - dtype: 'uint32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Data type. - */ - dtype: 'uint16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Data type. - */ - dtype: 'uint8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Data type. - */ - dtype: 'uint8c'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Data type. - */ - dtype: 'complex128'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Data type. - */ - dtype: 'complex64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Data type. - */ - dtype: 'generic'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array-float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array-int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array-int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array-int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array-uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array-uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array-complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 -* }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fdb3d5a..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e96b9a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cb7ed8f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 563ff3f829a4488644204f311002c77e5617c527 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:11:19 +0000 Subject: [PATCH 112/115] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 200 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 106 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 126 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 68 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 42 files changed, 4866 insertions(+), 4147 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 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 1548bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5cb4739..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 759ce41..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::typed_array', function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::array_like', function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 39828bf..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array uses accessors for getting - and setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5c49738..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,126 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @returns array-like object -*/ -function accessorArray(): AccessorArrayLike { - const arr: AccessorArrayLike = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @returns array-like object -*/ -function arrayLike(): ArrayLike { - const arr: ArrayLike = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 6dffd28..3a135f7 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..fdb3d5a --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 80bcb8b..3bf1120 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.2", - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-getter": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.2", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.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 +29,8 @@ "utils", "util" ], - "__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..cb7ed8f --- /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 6e41a3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); From 78c9beee7243af258c473ee4cf9191f8d8081f72 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 2 Dec 2025 01:12:08 +0000 Subject: [PATCH 113/115] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 12646ed..3db3a24 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "@stdlib/complex-float32-ctor": "^0.0.2", "@stdlib/complex-float32-imag": "^0.1.1", "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", "tap-min": "git+https://github.com/Planeshifter/tap-min.git", From 4a409f036c011258a0f4f3adcdfd04b78f99171a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 2 Dec 2025 01:12:25 +0000 Subject: [PATCH 114/115] Remove files --- index.d.ts | 1037 ----------- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5884 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 3a135f7..0000000 --- a/index.d.ts +++ /dev/null @@ -1,1037 +0,0 @@ -/* eslint-disable max-lines */ - -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; -import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; - -/** -* Returns an element from a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat64 = ( arr: Float64Array, idx: number ) => number | void; - -/** -* Returns an element from a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetFloat32 = ( arr: Float32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt32 = ( arr: Int32Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt16 = ( arr: Int16Array, idx: number ) => number | void; - -/** -* Returns an element from an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetInt8 = ( arr: Int8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint32 = ( arr: Uint32Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint16 = ( arr: Uint16Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8 = ( arr: Uint8Array, idx: number ) => number | void; - -/** -* Returns an element from a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetUint8c = ( arr: Uint8ClampedArray, idx: number ) => number | void; - -/** -* Returns an element from a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex128 = ( arr: Complex128Array, idx: number ) => Complex128 | void; - -/** -* Returns an element from a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetComplex64 = ( arr: Complex64Array, idx: number ) => Complex64 | void; - -/** -* Returns an element from a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetGeneric = ( arr: Array, idx: number ) => T | void; - -/** -* Returns an element from an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetIndexedArrayLike = ( arr: Collection, idx: number ) => T | void; - -/** -* Returns an element from an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @returns element value -*/ -type GetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number ) => T | void; - -/** -* Sets an element in a `Float64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat64 = ( arr: Float64Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Float32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetFloat32 = ( arr: Float32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt32 = ( arr: Int32Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt16 = ( arr: Int16Array, idx: number, value: number ) => void; - -/** -* Sets an element in an `Int8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetInt8 = ( arr: Int8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint32Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint32 = ( arr: Uint32Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint16Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint16 = ( arr: Uint16Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8 = ( arr: Uint8Array, idx: number, value: number ) => void; - -/** -* Sets an element in a `Uint8ClampedArray`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetUint8c = ( arr: Uint8ClampedArray, idx: number, value: number ) => void; - -/** -* Sets an element in a `Complex128Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex128 = ( arr: Complex128Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a `Complex64Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetComplex64 = ( arr: Complex64Array, idx: number, value: ComplexLike ) => void; - -/** -* Sets an element in a generic `Array`. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetGeneric = ( arr: Array, idx: number, value: T ) => void; - -/** -* Sets an element in an indexed array-like object. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetIndexedArrayLike = ( arr: Collection, idx: number, value: T ) => void; - -/** -* Sets an element in an array-like object supporting the get/set protocol. -* -* @param arr - input array -* @param idx - element index -* @param value - value to set -*/ -type SetAccessorArrayLike = ( arr: AccessorArrayLike, idx: number, value: T ) => void; - -/** -* Interface describing the output object for a `Float64Array`. -*/ -interface Float64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float64Array; - - /** - * Data type. - */ - dtype: 'float64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat64, SetFloat64 ]; -} - -/** -* Interface describing the output object for a `Float32Array`. -*/ -interface Float32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Float32Array; - - /** - * Data type. - */ - dtype: 'float32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetFloat32, SetFloat32 ]; -} - -/** -* Interface describing the output object for an `Int32Array`. -*/ -interface Int32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int32Array; - - /** - * Data type. - */ - dtype: 'int32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt32, SetInt32 ]; -} - -/** -* Interface describing the output object for an `Int16Array`. -*/ -interface Int16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int16Array; - - /** - * Data type. - */ - dtype: 'int16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt16, SetInt16 ]; -} - -/** -* Interface describing the output object for an `Int8Array`. -*/ -interface Int8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Int8Array; - - /** - * Data type. - */ - dtype: 'int8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetInt8, SetInt8 ]; -} - -/** -* Interface describing the output object for a `Uint32Array`. -*/ -interface Uint32AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint32Array; - - /** - * Data type. - */ - dtype: 'uint32'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint32, SetUint32 ]; -} - -/** -* Interface describing the output object for a `Uint16Array`. -*/ -interface Uint16AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint16Array; - - /** - * Data type. - */ - dtype: 'uint16'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint16, SetUint16 ]; -} - -/** -* Interface describing the output object for a `Uint8Array`. -*/ -interface Uint8AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8Array; - - /** - * Data type. - */ - dtype: 'uint8'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8, SetUint8 ]; -} - -/** -* Interface describing the output object for a `Uint8ClampedArray`. -*/ -interface Uint8cAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Uint8ClampedArray; - - /** - * Data type. - */ - dtype: 'uint8c'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetUint8c, SetUint8c ]; -} - -/** -* Interface describing the output object for a `Complex128Array`. -*/ -interface Complex128AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex128Array; - - /** - * Data type. - */ - dtype: 'complex128'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex128, SetComplex128 ]; -} - -/** -* Interface describing the output object for a `Complex64Array`. -*/ -interface Complex64AccessorObject { - /** - * Reference to the original array-like object. - */ - data: Complex64Array; - - /** - * Data type. - */ - dtype: 'complex64'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetComplex64, SetComplex64 ]; -} - -/** -* Interface describing the output object for a "generic" array not supporting the get/set protocol. -*/ -interface GenericAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Array; - - /** - * Data type. - */ - dtype: 'generic'; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetGeneric, SetGeneric ]; -} - -/** -* Interface describing the output object for an indexed array-like object. -*/ -interface IndexedAccessorObject { - /** - * Reference to the original array-like object. - */ - data: Collection; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: false; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetIndexedArrayLike, SetIndexedArrayLike ]; -} - -/** -* Interface describing the output object for an array-like object supporting the get/set protocol. -*/ -interface GetSetAccessorObject { - /** - * Reference to the original array-like object. - */ - data: AccessorArrayLike; - - /** - * Data type. - */ - dtype: string | null; - - /** - * Boolean indicating whether the provided array-like object supports the get/set protocol (i.e., uses accessors for getting and setting elements). - */ - accessorProtocol: true; - - /** - * Two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. - */ - accessors: [ GetAccessorArrayLike, SetAccessorArrayLike ]; -} - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* -* var x = new Float64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float64Array ): Float64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Float32Array = require( '@stdlib/array-float32' ); -* -* var x = new Float32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Float32Array ): Float32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int32Array = require( '@stdlib/array-int32' ); -* -* var x = new Int32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int32Array ): Int32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int16Array = require( '@stdlib/array-int16' ); -* -* var x = new Int16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int16Array ): Int16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Int8Array = require( '@stdlib/array-int8' ); -* -* var x = new Int8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Int8Array ): Int8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint32Array = require( '@stdlib/array-uint32' ); -* -* var x = new Uint32Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint32Array ): Uint32AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint16Array = require( '@stdlib/array-uint16' ); -* -* var x = new Uint16Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint16Array ): Uint16AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8Array = require( '@stdlib/array-uint8' ); -* -* var x = new Uint8Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8Array ): Uint8AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -* -* var x = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Uint8ClampedArray ): Uint8cAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex128Array = require( '@stdlib/array-complex128' ); -* -* var x = new Complex128Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex128Array ): Complex128AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var Complex64Array = require( '@stdlib/array-complex64' ); -* -* var x = new Complex64Array( [ 1, 2, 3, 4 ] ); -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x, 1 ); -* // returns -*/ -declare function arraylike2object( x: Complex64Array ): Complex64AccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* -* function get( idx ) { -* return x[ idx ]; -* } -* -* function set( value, idx ) { -* x[ idx ] = value; -* } -* -* x.get = get; -* x.set = set; -* -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns true -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: AccessorArrayLike ): GetSetAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = [ 1, 2, 3, 4 ]; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Array ): GenericAccessorObject; - -/** -* Converts a one-dimensional array-like object to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* @param x - input array -* @returns object containing array data -* -* @example -* var x = { -* '0': 1, -* '1': 2, -* '2': 3, -* '4': 4, -* 'length': 4 -* }; -* var obj = arraylike2object( x ); -* // returns {...} -* -* var bool = obj.accessorProtocol; -* // returns false -* -* var fcns = obj.accessors; -* // returns [ , ] -* -* var v = fcns[ 0 ]( x.data, 2 ); -* // returns 3 -*/ -declare function arraylike2object( x: Collection ): IndexedAccessorObject; - - -// EXPORTS // - -export = arraylike2object; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index fdb3d5a..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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1e96b9a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index cb7ed8f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 83d49dbe3dbf1f319814445edc0c2c9cda885c85 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 2 Dec 2025 01:13:05 +0000 Subject: [PATCH 115/115] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 202 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 107 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 58 - docs/types/test.ts | 126 - examples/index.js | 31 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 40 - lib/main.js | 81 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 131 - 43 files changed, 4865 insertions(+), 4262 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (99%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 48428f9..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7b01c7e..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5cb4739..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: '57 21 * * 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' - # 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 + + ```
@@ -167,7 +158,7 @@ console.log( obj ); ## 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]. @@ -230,7 +221,7 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-arraylike2object/main/LICENSE -[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype +[@stdlib/array/dtype]: https://github.com/stdlib-js/array-dtype/tree/esm
diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index e091814..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var Float64Array = require( '@stdlib/array-float64' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var arraylike2object = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::array', pkg ), function benchmark( b ) { - var values; - var out; - var i; - - values = [ - zeros( 10 ), - zeros( 10 ), - zeros( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::typed_array', pkg ), function benchmark( b ) { - var values; - var out; - var i; - - values = [ - new Float64Array( 10 ), - new Float64Array( 10 ), - new Float64Array( 10 ) - ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = arraylike2object( values[ i%values.length ] ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::array_like', pkg ), function benchmark( b ) { - var arr; - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = { - 'length': i - }; - out = arraylike2object( arr ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isCollection( out.data ) ) { - b.fail( 'should return a collection' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 446b0a7..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object" -%% click B href "https://github.com/stdlib-js/array-base-arraylike2object/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-arraylike2object/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-arraylike2object/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-arraylike2object/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-arraylike2object/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/arraylike2object -[production-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-arraylike2object/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-arraylike2object/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-arraylike2object/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 43193c9..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import arraylike2object from '../docs/types/index'; -export = arraylike2object; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index b1a00d9..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var s=a(function(y,t){ -var c=require('@stdlib/array-base-assert-is-accessor-array/dist'),o=require('@stdlib/array-base-getter/dist'),i=require('@stdlib/array-base-setter/dist'),u=require('@stdlib/array-base-accessor-getter/dist'),v=require('@stdlib/array-base-accessor-setter/dist'),q=require('@stdlib/array-dtype/dist');function d(e){var r=q(e);return c(e)?{data:e,dtype:r,accessorProtocol:!0,accessors:[u(r),v(r)]}:{data:e,dtype:r,accessorProtocol:!1,accessors:[o(r),i(r)]}}t.exports=d -});var n=s();module.exports=n; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index ebc32e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar getter = require( '@stdlib/array-base-getter' );\nvar setter = require( '@stdlib/array-base-setter' );\nvar accessorGetter = require( '@stdlib/array-base-accessor-getter' );\nvar accessorSetter = require( '@stdlib/array-base-accessor-setter' );\nvar dtype = require( '@stdlib/array-dtype' );\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nmodule.exports = arraylike2object;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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 array-like object to an object likely to have the same \"shape\".\n*\n* @module @stdlib/array-base-arraylike2object\n*\n* @example\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAkB,QAAS,6CAA8C,EACzEC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,QAAS,2BAA4B,EAC9CC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAQ,QAAS,qBAAsB,EA0B3C,SAASC,EAAkBC,EAAI,CAC9B,IAAIC,EAAKH,EAAOE,CAAE,EAClB,OAAKP,EAAiBO,CAAE,EAChB,CACN,KAAQA,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZL,EAAgBK,CAAG,EACnBJ,EAAgBI,CAAG,CACpB,CACD,EAEM,CACN,KAAQD,EACR,MAASC,EACT,iBAAoB,GACpB,UAAa,CACZP,EAAQO,CAAG,EACXN,EAAQM,CAAG,CACZ,CACD,CACD,CAKAT,EAAO,QAAUO,IC9CjB,IAAIG,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isAccessorArray", "getter", "setter", "accessorGetter", "accessorSetter", "dtype", "arraylike2object", "x", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 39828bf..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,58 +0,0 @@ - -{{alias}}( x ) - Converts an array-like object to an object likely to have the same "shape". - - The returned object has the following properties: - - - data: reference to input array. - - dtype: input array data type. - - accessorProtocol: boolean indicating whether the input array uses - accessors for getting and setting elements. - - accessors: a two-element array whose first element is an accessor for - retrieving an array element and whose second element is an accessor for - setting an array element. - - The getter accessor accepts two arguments: - - - data: data buffer. - - idx: element index. - - The setter accessor accepts three arguments: - - - data: data buffer. - - idx: element index. - - value: value to set. - - Parameters - ---------- - x: ArrayLikeObject - Input array. - - Returns - ------- - out: Object - Object containing array data. - - out.data: ArrayLikeObject - Reference to input array. - - out.dtype: string|null - Input array data type. - - out.accessorProtocol: boolean - Boolean indicating whether the input array uses accessors for getting - and setting elements. - - out.accessors: Array - A two-element array whose first element is an accessor for retrieving an - array element and whose second element is an accessor for setting an - array element. - - Examples - -------- - > var out = {{alias}}( [ 1, 2, 3, 4 ] ) - {...} - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 5c49738..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,126 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; -import Complex128Array = require( '@stdlib/array-complex128' ); -import Complex64Array = require( '@stdlib/array-complex64' ); -import arraylike2object = require( './index' ); - -/** -* Returns an array-like object supporting the get/set protocol. -* -* @returns array-like object -*/ -function accessorArray(): AccessorArrayLike { - const arr: AccessorArrayLike = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4, - 'get': ( idx: number ): number => { - return arr[ idx ]; - }, - 'set': ( value: number, idx: number ): void => { - arr[ idx ] = value; - } - }; - return arr; -} - -/** -* Returns an array-like object. -* -* @returns array-like object -*/ -function arrayLike(): ArrayLike { - const arr: ArrayLike = { - '0': 1, - '1': 2, - '2': 3, - '3': 4, - 'length': 4 - }; - return arr; -} - - -// TESTS // - -// The function returns an array object... -{ - const x1 = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object( x1 ); // $ExpectType GenericAccessorObject - - const x2 = new Float64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x2 ); // $ExpectType Float64AccessorObject - - const x3 = new Float32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x3 ); // $ExpectType Float32AccessorObject - - const x4 = new Int32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x4 ); // $ExpectType Int32AccessorObject - - const x5 = new Int16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x5 ); // $ExpectType Int16AccessorObject - - const x6 = new Int8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x6 ); // $ExpectType Int8AccessorObject - - const x7 = new Uint32Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x7 ); // $ExpectType Uint32AccessorObject - - const x8 = new Uint16Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x8 ); // $ExpectType Uint16AccessorObject - - const x9 = new Uint8Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x9 ); // $ExpectType Uint8AccessorObject - - const x10 = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x10 ); // $ExpectType Uint8cAccessorObject - - const x11 = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x11 ); // $ExpectType Complex128AccessorObject - - const x12 = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] ); - arraylike2object( x12 ); // $ExpectType Complex64AccessorObject - - const x13 = accessorArray(); - arraylike2object( x13 ); // $ExpectType GetSetAccessorObject - - const x14 = arrayLike(); - arraylike2object( x14 ); // $ExpectType IndexedAccessorObject -} - -// The compiler throws an error if the function is not provided an array-like object... -{ - arraylike2object( 123 ); // $ExpectError - arraylike2object( true ); // $ExpectError - arraylike2object( false ); // $ExpectError - arraylike2object( null ); // $ExpectError - arraylike2object( {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ 1, 2, 3, 4, 5, 6 ]; - arraylike2object(); // $ExpectError - arraylike2object( x, 5 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ab2c0c7..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 Complex64Array = require( '@stdlib/array-complex64' ); -var arraylike2object = require( './../lib' ); - -// Create an array: -var x = new Complex64Array( 10 ); - -// Convert to a standardized object: -var obj = arraylike2object( x ); -// returns {...} - -console.log( obj ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 99% rename from docs/types/index.d.ts rename to index.d.ts index 6dffd28..3a135f7 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -20,7 +20,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, Complex64Array, Complex128Array, AccessorArrayLike } from '@stdlib/types/array'; import { Complex64, Complex128, ComplexLike } from '@stdlib/types/complex'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3be60eb --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-getter@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-getter@v0.2.2-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";function o(o){var i=d(o);return s(o)?{data:o,dtype:i,accessorProtocol:!0,accessors:[t(i),a(i)]}:{data:o,dtype:i,accessorProtocol:!1,accessors:[e(i),r(i)]}}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1e96b9a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* 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 isAccessorArray from '@stdlib/array-base-assert-is-accessor-array';\nimport getter from '@stdlib/array-base-getter';\nimport setter from '@stdlib/array-base-setter';\nimport accessorGetter from '@stdlib/array-base-accessor-getter';\nimport accessorSetter from '@stdlib/array-base-accessor-setter';\nimport dtype from '@stdlib/array-dtype';\n\n\n// MAIN //\n\n/**\n* Converts an array-like to an object likely to have the same \"shape\".\n*\n* ## Notes\n*\n* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different \"hidden\" classes. If a function is provided many objects having different \"shapes\", some JavaScript VMs (e.g., V8) will consider the function \"megamorphic\" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the \"shape\" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument \"shapes\".\n*\n* - The returned object has the following properties:\n*\n* - **data**: reference to the input array.\n* - **dtype**: array data type.\n* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements.\n* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element.\n*\n* @param {Collection} x - array-like object\n* @returns {Object} object containing array meta data\n*\n* @example\n* var obj = arraylike2object( [ 1, 2, 3, 4 ] );\n* // returns {...}\n*/\nfunction arraylike2object( x ) {\n\tvar dt = dtype( x );\n\tif ( isAccessorArray( x ) ) {\n\t\treturn {\n\t\t\t'data': x,\n\t\t\t'dtype': dt,\n\t\t\t'accessorProtocol': true,\n\t\t\t'accessors': [\n\t\t\t\taccessorGetter( dt ),\n\t\t\t\taccessorSetter( dt )\n\t\t\t]\n\t\t};\n\t}\n\treturn {\n\t\t'data': x,\n\t\t'dtype': dt,\n\t\t'accessorProtocol': false,\n\t\t'accessors': [\n\t\t\tgetter( dt ),\n\t\t\tsetter( dt )\n\t\t]\n\t};\n}\n\n\n// EXPORTS //\n\nexport default arraylike2object;\n"],"names":["arraylike2object","x","dt","dtype","isAccessorArray","data","accessorProtocol","accessors","accessorGetter","accessorSetter","getter","setter"],"mappings":";;skBAqDA,SAASA,EAAkBC,GAC1B,IAAIC,EAAKC,EAAOF,GAChB,OAAKG,EAAiBH,GACd,CACNI,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZC,EAAgBN,GAChBO,EAAgBP,KAIZ,CACNG,KAAQJ,EACRE,MAASD,EACTI,kBAAoB,EACpBC,UAAa,CACZG,EAAQR,GACRS,EAAQT,IAGX"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index d9db294..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 array-like object to an object likely to have the same "shape". -* -* @module @stdlib/array-base-arraylike2object -* -* @example -* var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -* -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 3955f6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,81 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var getter = require( '@stdlib/array-base-getter' ); -var setter = require( '@stdlib/array-base-setter' ); -var accessorGetter = require( '@stdlib/array-base-accessor-getter' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var dtype = require( '@stdlib/array-dtype' ); - - -// MAIN // - -/** -* Converts an array-like to an object likely to have the same "shape". -* -* ## Notes -* -* - This function is intended as a potential performance optimization. In V8, for example, even if two objects share common properties, if those properties were added in different orders or if one object has additional properties not shared by the other object, then those objects will have different "hidden" classes. If a function is provided many objects having different "shapes", some JavaScript VMs (e.g., V8) will consider the function "megamorphic" and fail to perform various runtime optimizations. Accordingly, the intent of this function is to standardize the "shape" of the object holding array meta data to ensure that internal functions operating on arrays are provided consistent argument "shapes". -* -* - The returned object has the following properties: -* -* - **data**: reference to the input array. -* - **dtype**: array data type. -* - **accessorProtocol**: `boolean` indicating whether the input array uses accessors for getting and setting elements. -* - **accessors**: a two-element array whose first element is an accessor for retrieving an array element and whose second element is an accessor for setting an array element. -* -* @param {Collection} x - array-like object -* @returns {Object} object containing array meta data -* -* @example -* var obj = arraylike2object( [ 1, 2, 3, 4 ] ); -* // returns {...} -*/ -function arraylike2object( x ) { - var dt = dtype( x ); - if ( isAccessorArray( x ) ) { - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': true, - 'accessors': [ - accessorGetter( dt ), - accessorSetter( dt ) - ] - }; - } - return { - 'data': x, - 'dtype': dt, - 'accessorProtocol': false, - 'accessors': [ - getter( dt ), - setter( dt ) - ] - }; -} - - -// EXPORTS // - -module.exports = arraylike2object; diff --git a/package.json b/package.json index 3db3a24..3bf1120 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an array-like object to an object likely to have the same \"shape\".", "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,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-getter": "^0.2.2", - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-getter": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/types": "^0.4.3" - }, - "devDependencies": { - "@stdlib/array-base-zeros": "^0.2.2", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "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,7 +29,6 @@ "utils", "util" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cb7ed8f --- /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 6e41a3a..0000000 --- a/test/test.js +++ /dev/null @@ -1,131 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2022 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var arraylike2object = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof arraylike2object, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function converts an array to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Float64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'float64', - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array-like object to a standardized object', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = { - 'length': 10 - }; - - expected = { - 'data': x, - 'dtype': null, - 'accessorProtocol': false - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, 1.0 ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an array to a standardized object (data buffer accessors)', function test( t ) { - var expected; - var actual; - var x; - var v; - - x = new Complex64Array( 10 ); - - expected = { - 'data': x, - 'dtype': 'complex64', - 'accessorProtocol': true - }; - actual = arraylike2object( x ); - - t.strictEqual( actual.data, expected.data, 'returns expected value' ); - t.strictEqual( actual.dtype, expected.dtype, 'returns expected value' ); - t.strictEqual( actual.accessorProtocol, expected.accessorProtocol, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 0 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 0 ].length, 2, 'returns expected value' ); - t.strictEqual( typeof actual.accessors[ 1 ], 'function', 'returns expected value' ); - t.strictEqual( actual.accessors[ 1 ].length, 3, 'returns expected value' ); - - actual.accessors[ 1 ]( actual.data, 0, new Complex64( 1.0, 2.0 ) ); - v = actual.accessors[ 0 ]( actual.data, 0 ); - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -});