From f3a2080dfab32b51b4b610b9445afc1f245eb036 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 09:10:28 +0000 Subject: [PATCH 001/154] Auto-generated commit 9c0ead0893c3625c24e6378535f930fbe69fe0cf --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 212 ++++ index.d.ts | 49 + index.mjs | 4 + index.mjs.map | 1 + package.json | 38 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3503 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..33579fe --- /dev/null +++ b/README.md @@ -0,0 +1,212 @@ + + +# Contiguous Data Buffer + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Create a zero-filled contiguous linear ndarray data buffer. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs'; +``` + +#### buffer( dtype, size ) + +Returns a zero-filled contiguous linear ndarray data buffer. + +```javascript +var buf = buffer( 'float64', 3 ); +// returns [ 0.0, 0.0, 0.0 ] +``` + +The function supports the following data types: + +- `binary`: binary. +- `complex64`: single-precision complex floating-point numbers. +- `complex128`: double-precision complex floating-point numbers. +- `float32`: single-precision floating-point numbers. +- `float64`: double-precision floating-point numbers. +- `generic`: values of any type. +- `int16`: signed 16-bit integers. +- `int32`: signed 32-bit integers. +- `int8`: signed 8-bit integers. +- `uint16`: unsigned 16-bit integers. +- `uint32`: unsigned 32-bit integers. +- `uint8`: unsigned 8-bit integers. +- `uint8c`: unsigned clamped 8-bit integers. + +If provided an unknown or unsupported data type, the function returns `null`. + +```javascript +var buf = buffer( 'float', 3 ); +// returns null +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## 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..577afeb --- /dev/null +++ b/index.d.ts @@ -0,0 +1,49 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 { Buffer } from 'buffer'; +import { TypedArray } from '@stdlib/types/array'; +import { DataType } from '@stdlib/types/ndarray'; + +/** +* Array or typed array. +*/ +type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; + +/** +* Returns a zero-filled contiguous linear ndarray data buffer. +* +* @param dtype - data type +* @param size - buffer size +* @returns data buffer +* +* @example +* var buf = buffer( 'float64', 3 ); +* // returns [ 0.0, 0.0, 0.0 ] +*/ +declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length + + +// EXPORTS // + +export = buffer; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..aae1895 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";var t=r,e=n,s=function(r){var n;for(n=0;n[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar buffer = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n"],"names":["bufferCtors","require$$0","allocUnsafe","require$$1","zeros","v","i","length","lib","dtype","size","buf","push","generic","binary","ctor","typedarray"],"mappings":";;oLA4CA,ICtBIA,EAAcC,EACdC,EAAcC,EACdC,EDSJ,SAAgBC,GACf,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAEE,OAAQD,IAC1BD,EAAGC,GAAM,EAEV,OAAOD,GC+DR,IC9DAG,EDiDA,SAAiBC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAL,EAGJ,IADAK,EAAM,GACAL,EAAI,EAAGA,EAAII,EAAMJ,IACtBK,EAAIC,KAAM,GAEX,OAAOD,EA8CCE,CAASH,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OAAON,EAAOF,EAAaQ,IAsCnBI,CAAQJ,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIK,EAAOf,EAAaS,GACxB,OAAKM,EACG,IAAIA,EAAML,GAEX,KAwBAM,CAAYP,EAAOC"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..b7b3558 --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "@stdlib/ndarray-base-buffer", + "version": "0.0.0", + "description": "Create a zero-filled contiguous linear ndarray data buffer.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/ndarray-base-buffer.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdtypes", + "types", + "base", + "ndarray", + "data", + "buffer", + "buf", + "contiguous", + "linear", + "multidimensional", + "array", + "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..440ecc2 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From eb071c5c124ca7c77d183c16341fb6c1c0a2fcdc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 22:52:49 +0000 Subject: [PATCH 002/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bdee281..9d7cbd9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.0.x", "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -113,4 +114,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 57f4c7f264a5667be73d3b898f52ef44231e903e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:08:53 +0000 Subject: [PATCH 003/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2743 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 577afeb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index aae1895..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";var t=r,e=n,s=function(r){var n;for(n=0;n[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar buffer = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n"],"names":["bufferCtors","require$$0","allocUnsafe","require$$1","zeros","v","i","length","lib","dtype","size","buf","push","generic","binary","ctor","typedarray"],"mappings":";;oLA4CA,ICtBIA,EAAcC,EACdC,EAAcC,EACdC,EDSJ,SAAgBC,GACf,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAEE,OAAQD,IAC1BD,EAAGC,GAAM,EAEV,OAAOD,GC+DR,IC9DAG,EDiDA,SAAiBC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAL,EAGJ,IADAK,EAAM,GACAL,EAAI,EAAGA,EAAII,EAAMJ,IACtBK,EAAIC,KAAM,GAEX,OAAOD,EA8CCE,CAASH,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OAAON,EAAOF,EAAaQ,IAsCnBI,CAAQJ,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIK,EAAOf,EAAaS,GACxB,OAAKM,EACG,IAAIA,EAAML,GAEX,KAwBAM,CAAYP,EAAOC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 440ecc2..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From ca1bb4614b637cfad5a17b34f8559031259e6f50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:09:43 +0000 Subject: [PATCH 004/154] 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 | 238 -- benchmark/benchmark.length.js | 125 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 178 -- 39 files changed, 2712 insertions(+), 3863 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 c0547fc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T22:52:02.851Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6bbe078..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -155,7 +148,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index b103164..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index b7b63af..577afeb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ae60b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 2d960ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var buffer = require( './main.js' ); - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9d7cbd9..7cf6b42 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.0.x", - "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-complex128array": "^0.0.x", - "@stdlib/assert-is-complex64array": "^0.0.x", - "@stdlib/assert-is-float32array": "^0.0.x", - "@stdlib/assert-is-float64array": "^0.0.x", - "@stdlib/assert-is-int16array": "^0.0.x", - "@stdlib/assert-is-int32array": "^0.0.x", - "@stdlib/assert-is-int8array": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/assert-is-uint32array": "^0.0.x", - "@stdlib/assert-is-uint8array": "^0.0.x", - "@stdlib/assert-is-uint8clampedarray": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..d24c132 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 64cafe5f89c66a618a33c0335324f04f75acfe7e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 18:26:34 +0000 Subject: [PATCH 005/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bdee281..9d7cbd9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.0.x", "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -113,4 +114,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 65f3448eb0edfd18ab5ada78130f70bf88055175 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 06:17:21 +0000 Subject: [PATCH 006/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2743 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 577afeb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ae60b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d24c132..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 1148a3bf8ecbff109ac9cc5479a3801c1ad1a533 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 06:18:12 +0000 Subject: [PATCH 007/154] 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 | 238 -- benchmark/benchmark.length.js | 125 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 178 -- 39 files changed, 2712 insertions(+), 3863 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 3f02a96..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:41:46.671Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6bbe078..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -155,7 +148,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index b103164..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index b7b63af..577afeb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ae60b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 2d960ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var buffer = require( './main.js' ); - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9d7cbd9..7cf6b42 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.0.x", - "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-complex128array": "^0.0.x", - "@stdlib/assert-is-complex64array": "^0.0.x", - "@stdlib/assert-is-float32array": "^0.0.x", - "@stdlib/assert-is-float64array": "^0.0.x", - "@stdlib/assert-is-int16array": "^0.0.x", - "@stdlib/assert-is-int32array": "^0.0.x", - "@stdlib/assert-is-int8array": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/assert-is-uint32array": "^0.0.x", - "@stdlib/assert-is-uint8array": "^0.0.x", - "@stdlib/assert-is-uint8clampedarray": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..ddb84a1 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 4113da796f544538c1dc2eec56acafea694a5d65 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:09:43 +0000 Subject: [PATCH 008/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bdee281..9d7cbd9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.0.x", "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -113,4 +114,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From d420314ef26ce1b9d5a5fa1e9cd663a77518976b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:10:05 +0000 Subject: [PATCH 009/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2743 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 577afeb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ae60b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ddb84a1..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From d2b1040e3dfd15f0fbcc40e0206f10d3f88fcb7c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:11:03 +0000 Subject: [PATCH 010/154] 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 | 238 -- benchmark/benchmark.length.js | 125 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 178 -- 38 files changed, 2712 insertions(+), 3828 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6bbe078..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -155,7 +148,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index b103164..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index b7b63af..577afeb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ae60b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 2d960ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var buffer = require( './main.js' ); - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9d7cbd9..7cf6b42 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.0.x", - "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-complex128array": "^0.0.x", - "@stdlib/assert-is-complex64array": "^0.0.x", - "@stdlib/assert-is-float32array": "^0.0.x", - "@stdlib/assert-is-float64array": "^0.0.x", - "@stdlib/assert-is-int16array": "^0.0.x", - "@stdlib/assert-is-int32array": "^0.0.x", - "@stdlib/assert-is-int8array": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/assert-is-uint32array": "^0.0.x", - "@stdlib/assert-is-uint8array": "^0.0.x", - "@stdlib/assert-is-uint8clampedarray": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..50ea8ce --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 910ce19ea14409c343f143959ec01d6a7b07cdb1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:58:26 +0000 Subject: [PATCH 011/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bdee281..9d7cbd9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.0.x", "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -113,4 +114,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 27f43419c62eaae2d0ff8651601f297eeeec2e0d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 18:04:19 +0000 Subject: [PATCH 012/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2743 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 577afeb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ae60b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 50ea8ce..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 781e945a60f5b75b72a047d889b841b79d6c24d5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 18:05:10 +0000 Subject: [PATCH 013/154] 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 | 238 -- benchmark/benchmark.length.js | 125 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 178 -- 39 files changed, 2712 insertions(+), 3902 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 04f0cfa..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:43:56.619Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6bbe078..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -155,7 +148,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index b103164..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index b7b63af..577afeb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ae60b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 2d960ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var buffer = require( './main.js' ); - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9d7cbd9..7cf6b42 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.0.x", - "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-complex128array": "^0.0.x", - "@stdlib/assert-is-complex64array": "^0.0.x", - "@stdlib/assert-is-float32array": "^0.0.x", - "@stdlib/assert-is-float64array": "^0.0.x", - "@stdlib/assert-is-int16array": "^0.0.x", - "@stdlib/assert-is-int32array": "^0.0.x", - "@stdlib/assert-is-int8array": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/assert-is-uint32array": "^0.0.x", - "@stdlib/assert-is-uint8array": "^0.0.x", - "@stdlib/assert-is-uint8clampedarray": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..f87b994 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 9b653ac0bccb54b782b17209bf1e499d86b59be7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:49:07 +0000 Subject: [PATCH 014/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bdee281..9d7cbd9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.0.x", "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -113,4 +114,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From e135361ea4e13baa90c91d449994fead9f277e34 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 11:16:24 +0000 Subject: [PATCH 015/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2743 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 577afeb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ae60b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f87b994..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From abeab8e959f4afc18228a77408eff95882c92d7e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 11:17:14 +0000 Subject: [PATCH 016/154] 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 | 238 -- benchmark/benchmark.length.js | 125 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 178 -- 39 files changed, 2712 insertions(+), 3918 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 978c295..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:44:07.162Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6bbe078..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -155,7 +148,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index b103164..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index b7b63af..577afeb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ae60b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 2d960ce..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var buffer = require( './main.js' ); - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9d7cbd9..7cf6b42 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.0.x", - "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-complex128array": "^0.0.x", - "@stdlib/assert-is-complex64array": "^0.0.x", - "@stdlib/assert-is-float32array": "^0.0.x", - "@stdlib/assert-is-float64array": "^0.0.x", - "@stdlib/assert-is-int16array": "^0.0.x", - "@stdlib/assert-is-int32array": "^0.0.x", - "@stdlib/assert-is-int8array": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/assert-is-uint32array": "^0.0.x", - "@stdlib/assert-is-uint8array": "^0.0.x", - "@stdlib/assert-is-uint8clampedarray": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..376f1c1 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 8a3127fe7718440c92e5d65efa91e1c2ec970d54 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:17:57 +0000 Subject: [PATCH 017/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bdee281..9d7cbd9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.0.x", "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -113,4 +114,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 16f32578a1da70910312b064bda4a00645879426 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 23:55:58 +0000 Subject: [PATCH 018/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2743 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 577afeb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ae60b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376f1c1..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0e9267b496a06ccc8560bb3ee375fbdb7f80159a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 23:56:55 +0000 Subject: [PATCH 019/154] 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 | 238 -- benchmark/benchmark.length.js | 125 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 178 -- 39 files changed, 2712 insertions(+), 3918 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 90a7697..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:11:45.486Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6bbe078..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -155,7 +148,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index b103164..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index b7b63af..577afeb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ae60b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9d7cbd9..7cf6b42 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.0.x", - "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-complex128array": "^0.0.x", - "@stdlib/assert-is-complex64array": "^0.0.x", - "@stdlib/assert-is-float32array": "^0.0.x", - "@stdlib/assert-is-float64array": "^0.0.x", - "@stdlib/assert-is-int16array": "^0.0.x", - "@stdlib/assert-is-int32array": "^0.0.x", - "@stdlib/assert-is-int8array": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/assert-is-uint32array": "^0.0.x", - "@stdlib/assert-is-uint8array": "^0.0.x", - "@stdlib/assert-is-uint8clampedarray": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..e49949c --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From c883b1f89fd6c62d0510805c3a83de57421e6ec6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:01:46 +0000 Subject: [PATCH 020/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bdee281..9d7cbd9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.0.x", "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -113,4 +114,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 2ed4fd96c41634e7293295a80780027230737af5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 18:14:37 +0000 Subject: [PATCH 021/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2743 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 577afeb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ae60b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,EA8CCG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,EDiBAE,CAAOC,EAAaR,IAsCnBS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,KAwBAY,CAAYb,EAAOC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e49949c..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 8b9492129b893ffb74d387b695ebb2a05462fa76 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 18:15:24 +0000 Subject: [PATCH 022/154] 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 | 238 -- benchmark/benchmark.length.js | 125 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 178 - 39 files changed, 4067 insertions(+), 3918 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 0f303b2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:57:08.944Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6bbe078..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 463ae03..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: '18 18 * * 3' - - # 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 + + ```
@@ -155,7 +148,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index b103164..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index b7b63af..577afeb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ae60b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9d7cbd9..7cf6b42 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.0.x", - "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-complex128array": "^0.0.x", - "@stdlib/assert-is-complex64array": "^0.0.x", - "@stdlib/assert-is-float32array": "^0.0.x", - "@stdlib/assert-is-float64array": "^0.0.x", - "@stdlib/assert-is-int16array": "^0.0.x", - "@stdlib/assert-is-int32array": "^0.0.x", - "@stdlib/assert-is-int8array": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/assert-is-uint32array": "^0.0.x", - "@stdlib/assert-is-uint8array": "^0.0.x", - "@stdlib/assert-is-uint8clampedarray": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..62133cf --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From a504e94cd2b93981ac0835152e347f5d6fc1e2a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:42:47 +0000 Subject: [PATCH 023/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bdee281..9d7cbd9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.0.x", "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -113,4 +114,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 00c5a15d1da27a66463ae5cbb7f0059dc5df8d1a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 08:54:52 +0000 Subject: [PATCH 024/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4098 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 577afeb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ae60b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 62133cf..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 1b00cbcef626704cc06dc17997e626ba61b47e26 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 08:55:37 +0000 Subject: [PATCH 025/154] 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 | 238 -- benchmark/benchmark.length.js | 125 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 178 - 39 files changed, 4067 insertions(+), 3939 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 a8300aa..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:58:55.079Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6bbe078..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 463ae03..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: '18 18 * * 3' - - # 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 + + ```
@@ -155,7 +148,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index b103164..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index b7b63af..577afeb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ae60b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9d7cbd9..7cf6b42 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.0.x", - "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-complex128array": "^0.0.x", - "@stdlib/assert-is-complex64array": "^0.0.x", - "@stdlib/assert-is-float32array": "^0.0.x", - "@stdlib/assert-is-float64array": "^0.0.x", - "@stdlib/assert-is-int16array": "^0.0.x", - "@stdlib/assert-is-int32array": "^0.0.x", - "@stdlib/assert-is-int8array": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/assert-is-uint32array": "^0.0.x", - "@stdlib/assert-is-uint8array": "^0.0.x", - "@stdlib/assert-is-uint8clampedarray": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..5c4144a --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From c00b410674f7476d5d5fe4a00686ce59eb786ada Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 02:51:33 +0000 Subject: [PATCH 026/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index db0fd17..0497382 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.0.x", "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -113,4 +114,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 75c2d220e3b6960107d6d0040dac372d973c0a88 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 12:48:53 +0000 Subject: [PATCH 027/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4098 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 577afeb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ae60b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5c4144a..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 1cfe70e9f047df51a52d9c0a55002aaf80809239 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 12:49:31 +0000 Subject: [PATCH 028/154] 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 | 238 -- benchmark/benchmark.length.js | 125 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 178 - 39 files changed, 4067 insertions(+), 3944 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 aa65889..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:47:30.241Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6bbe078..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 463ae03..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: '18 18 * * 3' - - # 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 + + ```
@@ -155,7 +148,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index b103164..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index b7b63af..577afeb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..04ae60b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 0497382..7cf6b42 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.0.x", - "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-complex128array": "^0.0.x", - "@stdlib/assert-is-complex64array": "^0.0.x", - "@stdlib/assert-is-float32array": "^0.0.x", - "@stdlib/assert-is-float64array": "^0.0.x", - "@stdlib/assert-is-int16array": "^0.0.x", - "@stdlib/assert-is-int32array": "^0.0.x", - "@stdlib/assert-is-int8array": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/assert-is-uint32array": "^0.0.x", - "@stdlib/assert-is-uint8array": "^0.0.x", - "@stdlib/assert-is-uint8clampedarray": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..7d99438 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 40bb8c2069394680a222b79849ff5828dc388282 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 02:29:32 +0000 Subject: [PATCH 029/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c4f8144..7963e17 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.0.x", "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x" + "@stdlib/types": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.x", @@ -113,4 +114,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 6833eb49c6f55472abe6a39f399ab91d685ad8f7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 10:07:17 +0000 Subject: [PATCH 030/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4098 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 577afeb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 04ae60b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7d99438..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From ac82e58c5be507d3b34a9e74d93556b90037fe04 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 10:08:13 +0000 Subject: [PATCH 031/154] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 35 +- benchmark/benchmark.js | 238 - benchmark/benchmark.length.js | 125 - branches.md | 53 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 178 - 39 files changed, 6200 insertions(+), 3955 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 176c6a5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T02:28:53.237Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6bbe078..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 463ae03..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -155,7 +148,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index b103164..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index b7b63af..577afeb 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9a3f8e3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 7963e17..7cf6b42 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.0.x", - "@stdlib/ndarray-base-buffer-ctors": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.x", - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float32": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-int16": "^0.0.x", - "@stdlib/array-int32": "^0.0.x", - "@stdlib/array-int8": "^0.0.x", - "@stdlib/array-uint16": "^0.0.x", - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/array-uint8": "^0.0.x", - "@stdlib/array-uint8c": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/assert-is-buffer": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-complex128array": "^0.0.x", - "@stdlib/assert-is-complex64array": "^0.0.x", - "@stdlib/assert-is-float32array": "^0.0.x", - "@stdlib/assert-is-float64array": "^0.0.x", - "@stdlib/assert-is-int16array": "^0.0.x", - "@stdlib/assert-is-int32array": "^0.0.x", - "@stdlib/assert-is-int8array": "^0.0.x", - "@stdlib/assert-is-uint16array": "^0.0.x", - "@stdlib/assert-is-uint32array": "^0.0.x", - "@stdlib/assert-is-uint8array": "^0.0.x", - "@stdlib/assert-is-uint8clampedarray": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/buffer-from-array": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/ndarray-dtypes": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -109,9 +31,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..94547c0 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 5ce999e0bf03aee9dd733efbc445b4c990c4dac0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 15:57:32 +0000 Subject: [PATCH 032/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 72de19c..7833349 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.1.0", "@stdlib/ndarray-base-buffer-ctors": "^0.0.6", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/array-complex128": "^0.0.6", @@ -113,4 +114,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ba931c396df18766d9304c633b222937fd3d6a45 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 16:12:23 +0000 Subject: [PATCH 033/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6231 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 577afeb..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9a3f8e3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;oLAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 94547c0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f6b46ceaaa011d2b9e84240ae63b4dbbb09a11a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 16:13:21 +0000 Subject: [PATCH 034/154] 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 | 238 - benchmark/benchmark.length.js | 125 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 178 - 42 files changed, 6200 insertions(+), 4132 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6bbe078..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 463ae03..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: '18 18 * * 3' - - # 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 + + ```
@@ -166,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c399bf..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 2f57758..f1a4ae1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4ff0875 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;2LAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 7833349..af4b31c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-buffer-ctors": "^0.0.6", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.0.6", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-buffer": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-complex128array": "^0.0.7", - "@stdlib/assert-is-complex64array": "^0.1.0", - "@stdlib/assert-is-float32array": "^0.1.0", - "@stdlib/assert-is-float64array": "^0.1.0", - "@stdlib/assert-is-int16array": "^0.1.0", - "@stdlib/assert-is-int32array": "^0.1.0", - "@stdlib/assert-is-int8array": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.0", - "@stdlib/assert-is-uint32array": "^0.1.0", - "@stdlib/assert-is-uint8array": "^0.1.0", - "@stdlib/assert-is-uint8clampedarray": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..3aad7b1 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 06801129ca620da7a188df057b0463ec191f263a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 16:20:54 +0000 Subject: [PATCH 035/154] 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 98bf74d..ec34b35 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs'; +import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.0-esm/index.mjs'; ``` #### buffer( dtype, size ) @@ -114,7 +114,7 @@ var buf = buffer( 'float', 3 ); - - - - From 9fb79bb4fa1cded4520a61467528117c2c0bbd4d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 27 Sep 2023 13:08:55 +0000 Subject: [PATCH 039/154] 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 | 238 - benchmark/benchmark.length.js | 125 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 178 - test/test.js | 178 - 43 files changed, 6200 insertions(+), 4368 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 8ae9b42..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: '18 18 * * 3' - - # 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 + + ```
@@ -166,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c399bf..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 2f57758..f1a4ae1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f8f5469 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ba65812..6d7f41c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-buffer": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-complex128array": "^0.1.0", - "@stdlib/assert-is-complex64array": "^0.1.0", - "@stdlib/assert-is-float32array": "^0.1.0", - "@stdlib/assert-is-float64array": "^0.1.0", - "@stdlib/assert-is-int16array": "^0.1.0", - "@stdlib/assert-is-int32array": "^0.1.0", - "@stdlib/assert-is-int8array": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.0", - "@stdlib/assert-is-uint32array": "^0.1.0", - "@stdlib/assert-is-uint8array": "^0.1.0", - "@stdlib/assert-is-uint8clampedarray": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..1baeb4a --- /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 3593aca..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 2d9dd727dc9cb8a6c08c11571e302f1ef6f5ffe4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 27 Sep 2023 13:09:19 +0000 Subject: [PATCH 040/154] Update README.md for ESM bundle v0.1.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2cd3665..3f872d9 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs'; +import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.1.1-esm/index.mjs'; ``` #### buffer( dtype, size ) @@ -114,7 +114,7 @@ var buf = buffer( 'float', 3 ); - - - - From 44ee2f4659f346ea6f62f2ff4f0ae90dc60987a0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 01:46:57 +0000 Subject: [PATCH 044/154] 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 | 238 - benchmark/benchmark.length.js | 125 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 178 - test/test.js | 178 - 44 files changed, 6200 insertions(+), 4369 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 7a71a12..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:16:06.662Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 8ae9b42..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: '18 18 * * 3' - - # 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 + + ```
@@ -166,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c399bf..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 2f57758..f1a4ae1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f8f5469 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index ba65812..6d7f41c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-buffer": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-complex128array": "^0.1.0", - "@stdlib/assert-is-complex64array": "^0.1.0", - "@stdlib/assert-is-float32array": "^0.1.0", - "@stdlib/assert-is-float64array": "^0.1.0", - "@stdlib/assert-is-int16array": "^0.1.0", - "@stdlib/assert-is-int32array": "^0.1.0", - "@stdlib/assert-is-int8array": "^0.1.0", - "@stdlib/assert-is-uint16array": "^0.1.0", - "@stdlib/assert-is-uint32array": "^0.1.0", - "@stdlib/assert-is-uint8array": "^0.1.0", - "@stdlib/assert-is-uint8clampedarray": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..64c9eed --- /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 3593aca..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 0b38fd5a8ee979ac3752eb4adaf543c76062e4b7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 19:37:38 +0000 Subject: [PATCH 045/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 951b84e..9931c42 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.1.0", "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -113,4 +114,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 43850046f534f9d742ae00ad50379a86369d7308 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 02:44:17 +0000 Subject: [PATCH 046/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6231 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 f1a4ae1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f8f5469..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 64c9eed..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 10f99df97f56e7588b38944d2c13061d62adcd58 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 02:45:43 +0000 Subject: [PATCH 047/154] 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 | 238 - benchmark/benchmark.length.js | 125 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 178 - test/test.js | 178 - 43 files changed, 6200 insertions(+), 4368 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 8ae9b42..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: '18 18 * * 3' - - # 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 + + ```
@@ -166,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c399bf..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 2f57758..f1a4ae1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f8f5469 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9931c42..6d7f41c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-int16": "^0.1.0", - "@stdlib/array-int32": "^0.1.0", - "@stdlib/array-int8": "^0.1.0", - "@stdlib/array-uint16": "^0.1.0", - "@stdlib/array-uint32": "^0.1.0", - "@stdlib/array-uint8": "^0.1.0", - "@stdlib/array-uint8c": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-buffer": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-complex128array": "^0.1.0", - "@stdlib/assert-is-complex64array": "^0.1.0", - "@stdlib/assert-is-float32array": "^0.1.1", - "@stdlib/assert-is-float64array": "^0.1.1", - "@stdlib/assert-is-int16array": "^0.1.1", - "@stdlib/assert-is-int32array": "^0.1.1", - "@stdlib/assert-is-int8array": "^0.1.1", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/assert-is-uint32array": "^0.1.1", - "@stdlib/assert-is-uint8array": "^0.1.1", - "@stdlib/assert-is-uint8clampedarray": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..126b2b6 --- /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 3593aca..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 2b1d489565d8c84aa7f460101b48d6367034bc28 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 17:16:00 +0000 Subject: [PATCH 048/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f2390a7..dd8e139 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.1.0", "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.1.0" + "@stdlib/types": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -113,4 +114,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 5c318b6cfe99f204a1e12b8a6ffdbdaafcff0e99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 01:34:32 +0000 Subject: [PATCH 049/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6231 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 f1a4ae1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f8f5469..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 126b2b6..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 18066dfa68b9ed0fba32af9c0e79672c30bee6b9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 01:35:40 +0000 Subject: [PATCH 050/154] 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 | 238 - benchmark/benchmark.length.js | 125 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 178 - 44 files changed, 6200 insertions(+), 4232 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 7d99636..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:34:21.576Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 8ae9b42..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: '18 18 * * 3' - - # 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 + + ```
@@ -166,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c399bf..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 2f57758..f1a4ae1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f8f5469 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index dd8e139..6d7f41c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-buffer": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-complex128array": "^0.1.0", - "@stdlib/assert-is-complex64array": "^0.1.0", - "@stdlib/assert-is-float32array": "^0.1.1", - "@stdlib/assert-is-float64array": "^0.1.1", - "@stdlib/assert-is-int16array": "^0.1.1", - "@stdlib/assert-is-int32array": "^0.1.1", - "@stdlib/assert-is-int8array": "^0.1.1", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/assert-is-uint32array": "^0.1.1", - "@stdlib/assert-is-uint8array": "^0.1.1", - "@stdlib/assert-is-uint8clampedarray": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..4fe2772 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 2d65ea5adf6d38aa28e2d0183df6adfd15f29112 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 13:25:30 +0000 Subject: [PATCH 051/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6926793..a4b81ea 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.1.0", "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -113,4 +114,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d40f6ea0f7c38afa7242255c52dfce8f6e0121af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 11:23:21 +0000 Subject: [PATCH 052/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6231 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 f1a4ae1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f8f5469..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4fe2772..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7da1119448b2ebf1ce26d451041723b7419a12fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 11:24:18 +0000 Subject: [PATCH 053/154] 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 | 238 - benchmark/benchmark.length.js | 125 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 178 - 44 files changed, 6200 insertions(+), 4227 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (93%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 7531591..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T05:39:15.901Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 8ae9b42..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: '18 18 * * 3' - - # 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 + + ```
@@ -166,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 44ce61b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 8fd5af3..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c399bf..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 1325c50..5f648ee 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f8f5469 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index a4b81ea..6d7f41c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-buffer": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-complex128array": "^0.1.0", - "@stdlib/assert-is-complex64array": "^0.1.0", - "@stdlib/assert-is-float32array": "^0.1.1", - "@stdlib/assert-is-float64array": "^0.1.1", - "@stdlib/assert-is-int16array": "^0.1.1", - "@stdlib/assert-is-int32array": "^0.1.1", - "@stdlib/assert-is-int8array": "^0.1.1", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/assert-is-uint32array": "^0.1.1", - "@stdlib/assert-is-uint8array": "^0.1.1", - "@stdlib/assert-is-uint8clampedarray": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..ffaf516 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From b1e901be6b47ff731d0da7e0e3db025b82bd7aa5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 07:59:35 +0000 Subject: [PATCH 054/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 66b6786..0771c87 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.1.0", "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -113,4 +114,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e424eaa727199b63036e716ada4328867a4c0a1f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:35:57 +0000 Subject: [PATCH 055/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6231 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 5f648ee..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f8f5469..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ffaf516..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 07ed7b3e4d7f00a766a68b8df1d2530b22256719 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:36:15 +0000 Subject: [PATCH 056/154] 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 | 238 - benchmark/benchmark.length.js | 125 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 178 - 45 files changed, 6200 insertions(+), 4233 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (93%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 2cdc06a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:08:37.184Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 4ddd3a7..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: '18 18 * * 3' - - # 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 + + ```
@@ -166,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 5ad897a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c8f5160..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 0c399bf..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 1325c50..5f648ee 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7e316d3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 0771c87..6d7f41c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-buffer": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-complex128array": "^0.1.0", - "@stdlib/assert-is-complex64array": "^0.1.0", - "@stdlib/assert-is-float32array": "^0.1.1", - "@stdlib/assert-is-float64array": "^0.1.1", - "@stdlib/assert-is-int16array": "^0.1.1", - "@stdlib/assert-is-int32array": "^0.1.1", - "@stdlib/assert-is-int8array": "^0.1.1", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/assert-is-uint32array": "^0.1.1", - "@stdlib/assert-is-uint8array": "^0.1.1", - "@stdlib/assert-is-uint8clampedarray": "^0.1.1", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -109,9 +31,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..09b7567 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From dba1b35656d55ed7516a76ff992f2c17abbd75c7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 08:31:25 +0000 Subject: [PATCH 057/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 66b6786..0771c87 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.1.0", "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.2.0" + "@stdlib/types": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -113,4 +114,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 5b9fe633335b4f63081d73674078daa594b1e206 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 13:57:57 +0000 Subject: [PATCH 058/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6231 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 5f648ee..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7e316d3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 09b7567..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2fdb11c505b1b976147a15c236363c2690260c6f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 13:58:20 +0000 Subject: [PATCH 059/154] 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 | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 238 - benchmark/benchmark.length.js | 125 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 178 - 45 files changed, 6200 insertions(+), 4238 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (93%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 f699c11..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T05:58:14.557Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 4ddd3a7..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: '18 18 * * 3' - - # 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 + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 5ad897a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c8f5160..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 1325c50..5f648ee 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7e316d3 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 0771c87..6d7f41c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.1.0", - "@stdlib/ndarray-base-buffer-ctors": "^0.1.0", - "@stdlib/types": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.1.1", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-int16": "^0.1.1", - "@stdlib/array-int32": "^0.1.1", - "@stdlib/array-int8": "^0.1.1", - "@stdlib/array-uint16": "^0.1.1", - "@stdlib/array-uint32": "^0.1.1", - "@stdlib/array-uint8": "^0.1.1", - "@stdlib/array-uint8c": "^0.1.1", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-buffer": "^0.1.1", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-complex128array": "^0.1.0", - "@stdlib/assert-is-complex64array": "^0.1.0", - "@stdlib/assert-is-float32array": "^0.1.1", - "@stdlib/assert-is-float64array": "^0.1.1", - "@stdlib/assert-is-int16array": "^0.1.1", - "@stdlib/assert-is-int32array": "^0.1.1", - "@stdlib/assert-is-int8array": "^0.1.1", - "@stdlib/assert-is-uint16array": "^0.1.1", - "@stdlib/assert-is-uint32array": "^0.1.1", - "@stdlib/assert-is-uint8array": "^0.1.1", - "@stdlib/assert-is-uint8clampedarray": "^0.1.1", - "@stdlib/buffer-from-array": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-dtypes": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -109,9 +31,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..41a5706 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From d662bd64927efd8e758a60a1d74e0cebc97d9e79 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 00:11:06 +0000 Subject: [PATCH 060/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 36d1776..0d56a39 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.0", "@stdlib/ndarray-base-buffer-ctors": "^0.2.0", - "@stdlib/types": "^0.3.1" + "@stdlib/types": "^0.3.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/array-complex128": "^0.1.0", @@ -113,4 +114,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7a572450c82a7670fc0c5c878cede80fa18923fb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 02:58:11 +0000 Subject: [PATCH 061/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6231 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 5f648ee..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7e316d3..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.1.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 41a5706..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3669d4f87bfbbf94d6cbdf14be21e608c1c14669 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 02:58:45 +0000 Subject: [PATCH 062/154] 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 | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 238 - benchmark/benchmark.length.js | 125 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 178 - 44 files changed, 6200 insertions(+), 4241 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (93%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 834be61..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: '18 18 * * 3' - - # 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 + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 5ad897a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c8f5160..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 1325c50..5f648ee 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c9acf3a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.0-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 0d56a39..0d632e3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.0", - "@stdlib/ndarray-base-buffer-ctors": "^0.2.0", - "@stdlib/types": "^0.3.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float32": "^0.2.0", - "@stdlib/array-float64": "^0.2.0", - "@stdlib/array-int16": "^0.2.0", - "@stdlib/array-int32": "^0.2.0", - "@stdlib/array-int8": "^0.2.0", - "@stdlib/array-uint16": "^0.2.0", - "@stdlib/array-uint32": "^0.2.0", - "@stdlib/array-uint8": "^0.2.0", - "@stdlib/array-uint8c": "^0.2.0", - "@stdlib/assert-is-array": "^0.2.0", - "@stdlib/assert-is-buffer": "^0.2.0", - "@stdlib/assert-is-collection": "^0.2.0", - "@stdlib/assert-is-complex128array": "^0.1.0", - "@stdlib/assert-is-complex64array": "^0.1.0", - "@stdlib/assert-is-float32array": "^0.2.0", - "@stdlib/assert-is-float64array": "^0.2.0", - "@stdlib/assert-is-int16array": "^0.2.0", - "@stdlib/assert-is-int32array": "^0.2.0", - "@stdlib/assert-is-int8array": "^0.2.0", - "@stdlib/assert-is-uint16array": "^0.2.0", - "@stdlib/assert-is-uint32array": "^0.2.0", - "@stdlib/assert-is-uint8array": "^0.2.0", - "@stdlib/assert-is-uint8clampedarray": "^0.2.0", - "@stdlib/buffer-from-array": "^0.2.0", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..db2eb98 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 1afd90d82e983cc9cad887dd9dad10e332f20e12 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:42:33 +0000 Subject: [PATCH 063/154] 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 4770f4b..d6dbe11 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs'; +import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.0-esm/index.mjs'; ``` #### buffer( dtype, size ) @@ -114,7 +114,7 @@ var buf = buffer( 'float', 3 ); - - - - From 8493e231d49bbf5913187f65cc2db8ac91c6898d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 19:32:50 +0000 Subject: [PATCH 067/154] 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 | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 238 - benchmark/benchmark.length.js | 125 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 178 - 44 files changed, 4865 insertions(+), 4235 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (93%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 5ad897a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c8f5160..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 1325c50..5f648ee 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..391b94e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 244573b..20ae8c2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-buffer-ctors": "^0.2.0", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.0", - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-buffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-complex128array": "^0.2.0", - "@stdlib/assert-is-complex64array": "^0.2.0", - "@stdlib/assert-is-float32array": "^0.2.1", - "@stdlib/assert-is-float64array": "^0.2.1", - "@stdlib/assert-is-int16array": "^0.2.1", - "@stdlib/assert-is-int32array": "^0.2.1", - "@stdlib/assert-is-int8array": "^0.2.1", - "@stdlib/assert-is-uint16array": "^0.2.1", - "@stdlib/assert-is-uint32array": "^0.2.1", - "@stdlib/assert-is-uint8array": "^0.2.1", - "@stdlib/assert-is-uint8clampedarray": "^0.2.1", - "@stdlib/buffer-from-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..6c3e766 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From f8988b3ea79ce9b5e1852f9f6bd12ac8ad13868a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:02:04 +0000 Subject: [PATCH 068/154] 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 e842a2c..bb3c65f 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs'; +import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.2.1-esm/index.mjs'; ``` #### buffer( dtype, size ) @@ -114,7 +114,7 @@ var buf = buffer( 'float', 3 ); - - - - From f7cd9fb5b497d5350374ddb040b8329471200dac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 13:35:10 +0000 Subject: [PATCH 072/154] 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 | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 238 - benchmark/benchmark.length.js | 125 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 178 - 45 files changed, 4865 insertions(+), 4237 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (93%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 8feb912..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T05:40:32.859Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 5ad897a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c8f5160..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 1325c50..5f648ee 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..20eaec4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 1951203..20ae8c2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-buffer-ctors": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-buffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-complex128array": "^0.2.1", - "@stdlib/assert-is-complex64array": "^0.2.1", - "@stdlib/assert-is-float32array": "^0.2.1", - "@stdlib/assert-is-float64array": "^0.2.1", - "@stdlib/assert-is-int16array": "^0.2.1", - "@stdlib/assert-is-int32array": "^0.2.1", - "@stdlib/assert-is-int8array": "^0.2.1", - "@stdlib/assert-is-uint16array": "^0.2.1", - "@stdlib/assert-is-uint32array": "^0.2.1", - "@stdlib/assert-is-uint8array": "^0.2.1", - "@stdlib/assert-is-uint8clampedarray": "^0.2.1", - "@stdlib/buffer-from-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..65cb960 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 05025353ea96e9f2e46a0ca00dc7cc25bee0aecf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:09:48 +0000 Subject: [PATCH 073/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fcd9209..1951203 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.1", "@stdlib/ndarray-base-buffer-ctors": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.2.1", @@ -113,4 +114,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From eabe659abe204b8e6f154bd748783a3d93787207 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:33:49 +0000 Subject: [PATCH 074/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 5f648ee..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 20eaec4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 65cb960..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 666d691c9bd6df1721d42d6fbbbccff847864804 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:34:05 +0000 Subject: [PATCH 075/154] 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 | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 238 - benchmark/benchmark.length.js | 125 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 178 - 45 files changed, 4865 insertions(+), 4240 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (93%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 a918d3b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T04:58:50.665Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 5ad897a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c8f5160..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 1325c50..5f648ee 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..20eaec4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 1951203..20ae8c2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-buffer-ctors": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-buffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-complex128array": "^0.2.1", - "@stdlib/assert-is-complex64array": "^0.2.1", - "@stdlib/assert-is-float32array": "^0.2.1", - "@stdlib/assert-is-float64array": "^0.2.1", - "@stdlib/assert-is-int16array": "^0.2.1", - "@stdlib/assert-is-int32array": "^0.2.1", - "@stdlib/assert-is-int8array": "^0.2.1", - "@stdlib/assert-is-uint16array": "^0.2.1", - "@stdlib/assert-is-uint32array": "^0.2.1", - "@stdlib/assert-is-uint8array": "^0.2.1", - "@stdlib/assert-is-uint8clampedarray": "^0.2.1", - "@stdlib/buffer-from-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..65cb960 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 9ec9b941db767470c21f80585a1500b98c930437 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:27:39 +0000 Subject: [PATCH 076/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fcd9209..1951203 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.1", "@stdlib/ndarray-base-buffer-ctors": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-complex128": "^0.2.1", @@ -113,4 +114,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d0bbc5eb443e1a13047f64e4bc85bab20bd6d0d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 08:50:02 +0000 Subject: [PATCH 077/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 5f648ee..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 20eaec4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 65cb960..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From df87bb61f559625651909bb1b9c6acb2308ecddf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 08:50:17 +0000 Subject: [PATCH 078/154] 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 | 37 +- SECURITY.md | 5 - benchmark/benchmark.js | 238 - benchmark/benchmark.length.js | 125 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 41 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 85 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 178 - 44 files changed, 4865 insertions(+), 4241 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (93%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -168,7 +159,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/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 5ad897a..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,238 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index c8f5160..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,125 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a zero-filled contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 5dcf5fe..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,41 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a zero-filled contiguous linear ndarray data buffer. - - The function supports the following data types: - - - binary: binary. - - complex64: single-precision complex floating-point numbers. - - complex128: double-precision complex floating-point numbers. - - float32: single-precision floating-point numbers. - - float64: double-precision floating-point numbers. - - generic: values of any type. - - int16: signed 16-bit integers. - - int32: signed 32-bit integers. - - int8: signed 8-bit integers. - - uint16: unsigned 16-bit integers. - - uint32: unsigned 32-bit integers. - - uint8: unsigned 8-bit integers. - - uint8c: unsigned clamped 8-bit integers. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 745696b..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); -var buf; -var i; - -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 1325c50..5f648ee 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..20eaec4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index faaddbf..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a zero-filled contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index a6b5f53..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a zero-filled typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} zero-filled typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 1951203..20ae8c2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a zero-filled contiguous linear ndarray data buffer.", "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,61 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-buffer-ctors": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-buffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-complex128array": "^0.2.1", - "@stdlib/assert-is-complex64array": "^0.2.1", - "@stdlib/assert-is-float32array": "^0.2.1", - "@stdlib/assert-is-float64array": "^0.2.1", - "@stdlib/assert-is-int16array": "^0.2.1", - "@stdlib/assert-is-int32array": "^0.2.1", - "@stdlib/assert-is-int8array": "^0.2.1", - "@stdlib/assert-is-uint16array": "^0.2.1", - "@stdlib/assert-is-uint32array": "^0.2.1", - "@stdlib/assert-is-uint8array": "^0.2.1", - "@stdlib/assert-is-uint8clampedarray": "^0.2.1", - "@stdlib/buffer-from-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^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", @@ -109,9 +31,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..65cb960 --- /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 d1fa678..0000000 --- a/test/test.js +++ /dev/null @@ -1,178 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns zero-filled contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From b8d3ebfb903c11ab3ab71bbb1cb26cd1808fbdec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 09:39:17 +0000 Subject: [PATCH 079/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0f139ea..24af61b 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.1", "@stdlib/ndarray-base-buffer-ctors": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-bool": "^0.0.1", @@ -115,4 +116,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2df2312df43d603eb0aa0e7d1db044a6e5e5d537 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 09:46:33 +0000 Subject: [PATCH 080/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 5f648ee..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | Buffer | null; - -/** -* Returns a zero-filled contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 20eaec4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 65cb960..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 804f7b2099f1d22a1e44e7d921269eb6a6963c06 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 13 Jul 2024 09:47:05 +0000 Subject: [PATCH 081/154] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 107 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 87 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 44 files changed, 4866 insertions(+), 4413 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0ded610..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..20eaec4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2966557..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 24af61b..10aaab6 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create a contiguous linear ndarray data buffer.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.1", - "@stdlib/ndarray-base-buffer-ctors": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.0.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-int16": "^0.2.1", - "@stdlib/array-int32": "^0.2.1", - "@stdlib/array-int8": "^0.2.1", - "@stdlib/array-uint16": "^0.2.1", - "@stdlib/array-uint32": "^0.2.1", - "@stdlib/array-uint8": "^0.2.1", - "@stdlib/array-uint8c": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-booleanarray": "^0.0.1", - "@stdlib/assert-is-buffer": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-complex128array": "^0.2.1", - "@stdlib/assert-is-complex64array": "^0.2.1", - "@stdlib/assert-is-float32array": "^0.2.1", - "@stdlib/assert-is-float64array": "^0.2.1", - "@stdlib/assert-is-int16array": "^0.2.1", - "@stdlib/assert-is-int32array": "^0.2.1", - "@stdlib/assert-is-int8array": "^0.2.1", - "@stdlib/assert-is-uint16array": "^0.2.1", - "@stdlib/assert-is-uint32array": "^0.2.1", - "@stdlib/assert-is-uint8array": "^0.2.1", - "@stdlib/assert-is-uint8clampedarray": "^0.2.1", - "@stdlib/buffer-from-array": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-dtypes": "^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", @@ -111,9 +31,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..51bf954 --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 2cba833addc864e189020cbcaadcb5ad10ece79e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 02:43:42 +0000 Subject: [PATCH 082/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1b625ca..3056905 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.2.1", - "@stdlib/types": "^0.3.2" + "@stdlib/types": "^0.3.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.0.1", @@ -115,4 +116,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 82c6d9bbdd875aeddd4ab0d665688dfd4f091e7c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 02:50:53 +0000 Subject: [PATCH 083/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 20eaec4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.1-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 51bf954..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a449342a58e1a9764b083f32a858502f43968928 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 02:51:11 +0000 Subject: [PATCH 084/154] 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 | 220 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 87 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 44 files changed, 4866 insertions(+), 4528 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.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 c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0ded610..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..73baaa6 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2966557..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 3056905..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.0.1", - "@stdlib/array-complex128": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.1", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.1", - "@stdlib/assert-is-complex64array": "^0.2.1", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -111,9 +31,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..1cbd90e --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From bea1885a537e2a458b7310727217c98ab43296bb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 02:56:52 +0000 Subject: [PATCH 085/154] Update README.md for ESM bundle v0.3.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d506a0e..367a800 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs'; +import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.0-esm/index.mjs'; ``` #### buffer( dtype, size ) @@ -102,7 +102,7 @@ var buf = buffer( 'float', 3 ); - - - - From d4cebbbddbd8e1dd6f8996f193a9da2d60cce971 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 12:53:35 +0000 Subject: [PATCH 089/154] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 148 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 87 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4866 insertions(+), 4457 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 02a1ca0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T05:51:07.459Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0ded610..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b154720 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2966557..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 8b4d1cd..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -111,9 +31,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..35f101c --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 842c381af09d1833ac26874dccaaaf1c6eedfb29 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:21:48 +0000 Subject: [PATCH 090/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9cf941f..1ea7bf3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.1" + "@stdlib/types": "^0.4.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -115,4 +116,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2a7f06a9d5f26d75a7f52493778724046e37c194 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 12:45:31 +0000 Subject: [PATCH 091/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b154720..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 35f101c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0a015da91e4cf89c4e7ff09ac00094a75578a7b1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 12:45:45 +0000 Subject: [PATCH 092/154] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 87 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4866 insertions(+), 4528 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 247d1b9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T06:17:41.138Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0ded610..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b154720 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2966557..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 1ea7bf3..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -111,9 +31,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..35f101c --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From d475553257ac2f83ca5452f23c052208c103749d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 08:39:00 +0000 Subject: [PATCH 093/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9cf941f..1ea7bf3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.1" + "@stdlib/types": "^0.4.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -115,4 +116,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6faf04ec3f9124e58d90e98f68e7098b0b8a44f9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 13:20:27 +0000 Subject: [PATCH 094/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b154720..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 35f101c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ab7b472be6c0ca86073dd9d2df306e21f0d9321c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 13:20:47 +0000 Subject: [PATCH 095/154] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 87 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4866 insertions(+), 4528 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4c3faaa..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T06:29:51.535Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0ded610..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b154720 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2966557..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 1ea7bf3..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -111,9 +31,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..35f101c --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 3a1367cc016f37ba3c14b76e4b7c08990bbb76c0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 08:25:47 +0000 Subject: [PATCH 096/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9cf941f..1ea7bf3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.1" + "@stdlib/types": "^0.4.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -115,4 +116,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From fc5a39975fead68ec99c4945c200966d4d1758c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 12:23:20 +0000 Subject: [PATCH 097/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b154720..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 35f101c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 874452eef498a431fbc9193069a2403248605543 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 12:23:39 +0000 Subject: [PATCH 098/154] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 87 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4866 insertions(+), 4528 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 11acd22..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T06:33:03.694Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0ded610..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b154720 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2966557..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 1ea7bf3..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -111,9 +31,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..35f101c --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 747f7f01074cff688a20a42fa076f6b62bdb41ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:42:22 +0000 Subject: [PATCH 099/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d732d95..9a7e8a3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -115,4 +116,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3c57802362504613650492f269efdffd3a866517 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 12:46:51 +0000 Subject: [PATCH 100/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b154720..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 35f101c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 43e9c5a95dbdfa813e51039a0f05562bbd2b5395 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 12:47:12 +0000 Subject: [PATCH 101/154] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 46 files changed, 4866 insertions(+), 4633 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d113c07..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T06:42:49.009Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0ded610..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b154720 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2966557..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9a7e8a3..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -111,9 +31,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..35f101c --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 77c17df6cb86970df6b6918492e4574b51e4e99b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 02:41:57 +0000 Subject: [PATCH 102/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d732d95..9a7e8a3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -115,4 +116,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 865346495dd8e6adb645855886997336c39e3540 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:41:08 +0000 Subject: [PATCH 103/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b154720..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 35f101c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 402b2dc291cd6eec3be0f4aad2da2f8ef326c9f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:41:28 +0000 Subject: [PATCH 104/154] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 46 files changed, 4866 insertions(+), 4633 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6dcf311..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T02:25:41.260Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c4eb32a..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0ded610..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b154720 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2966557..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9a7e8a3..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -111,9 +31,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..35f101c --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From d03313f0e1b2b9ff7ce31782e059c1e684b532c8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 01:04:43 +0000 Subject: [PATCH 105/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d732d95..9a7e8a3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -115,4 +116,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 59ca49ac26f4c45528f5ce17db79dbf04a7c7730 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 01:32:34 +0000 Subject: [PATCH 106/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b154720..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 35f101c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 30228d35fa5d02448bf5883df455ce262c5935af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Mar 2025 01:32:54 +0000 Subject: [PATCH 107/154] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 46 files changed, 4866 insertions(+), 4636 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b890651..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-24T01:00:56.179Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0ded610..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e4ff49c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2966557..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9a7e8a3..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -111,9 +31,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..35f101c --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From a9c14d4a55de3f2e2a00f00d2a6d174de8993fbb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:32:42 +0000 Subject: [PATCH 108/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d732d95..9a7e8a3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -115,4 +116,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ce804b6c757717d47d2bc6035125af972f09f974 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:57:07 +0000 Subject: [PATCH 109/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e4ff49c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 35f101c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f6100991628b5cc300dd0f766a05f302f13d5ed4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 7 Apr 2025 01:57:30 +0000 Subject: [PATCH 110/154] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 46 files changed, 4866 insertions(+), 4636 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0268449..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-04-07T01:30:58.246Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0ded610..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e4ff49c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2966557..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9a7e8a3..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -111,9 +31,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..35f101c --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From c818fc90f6790c7f8292d79660703568ec1eb6b4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 00:35:02 +0000 Subject: [PATCH 111/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d732d95..9a7e8a3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,8 @@ "dependencies": { "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -115,4 +116,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f214b3a228491e77e8b7b46382bc86445c4f93d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 00:36:24 +0000 Subject: [PATCH 112/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e4ff49c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 35f101c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5ba2e3954565aaaf6fe97f65497ce3c5b529c9f3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 00:36:53 +0000 Subject: [PATCH 113/154] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 102 - lib/zeros.js | 45 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 46 files changed, 4866 insertions(+), 4636 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/zeros.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0c16d0d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-26T00:34:19.290Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d973647..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var i=u(function(h,t){ -function o(e){var r;for(r=0;r[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAiCA,SAASC,EAAOC,EAAI,CACnB,IAAIC,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAE,OAAQC,IAC1BD,EAAGC,CAAE,EAAI,EAEV,OAAOD,CACR,CAKAF,EAAO,QAAUC,IC5CjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,IAYZ,SAASC,EAASC,EAAO,CACxB,IAAIC,EACAC,EAGJ,IADAD,EAAM,CAAC,EACDC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAI,KAAM,CAAE,EAEb,OAAOA,CACR,CASA,SAASE,EAAQH,EAAO,CACvB,OAAOF,EAAOD,EAAaG,CAAK,CAAE,CACnC,CAUA,SAASI,EAAYC,EAAOL,EAAO,CAClC,IAAIM,EAAOV,EAAaS,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMN,CAAK,EAEhB,IACR,CAgBA,SAASO,EAAQF,EAAOL,EAAO,CAC9B,OAAKK,IAAU,UACPN,EAASC,CAAK,EAEjBK,IAAU,SACPF,EAAQH,CAAK,EAEdI,EAAYC,EAAOL,CAAK,CAChC,CAKAL,EAAO,QAAUY,ICnEjB,IAAIC,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_zeros", "__commonJSMin", "exports", "module", "zeros", "v", "i", "require_main", "__commonJSMin", "exports", "module", "bufferCtors", "allocUnsafe", "zeros", "generic", "size", "buf", "i", "binary", "typedarray", "dtype", "ctor", "buffer", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 0ded610..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..e4ff49c --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2966557..0000000 --- a/lib/main.js +++ /dev/null @@ -1,102 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( './zeros.js' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled generic array. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Array} zero-filled generic array -*/ -function generic( size ) { - var buf; - var i; - - buf = []; - for ( i = 0; i < size; i++ ) { - buf.push( 0 ); - } - return buf; -} - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return zeros( allocUnsafe( size ) ); -} - -/** -* Returns a typed array. -* -* @private -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {string} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - if ( dtype === 'generic' ) { - return generic( size ); - } - if ( dtype === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/lib/zeros.js b/lib/zeros.js deleted file mode 100644 index 0d00458..0000000 --- a/lib/zeros.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 // - -/** -* Fills an array-like object with zeros. -* -* @private -* @param {(Array|TypedArray|Buffer)} v - array-like object to fill -* @returns {(Array|TypedArray|Buffer)} input value -* -* @example -* var arr = zeros( new Array( 2 ) ); -* // returns [ 0, 0 ] -*/ -function zeros( v ) { - var i; - for ( i = 0; i < v.length; i++ ) { - v[ i ] = 0; - } - return v; -} - - -// EXPORTS // - -module.exports = zeros; diff --git a/package.json b/package.json index 9a7e8a3..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,63 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -111,9 +31,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..35f101c --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From b66f38b34fa0b92dc32ce2c0245cffc77f97639d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 19:25:32 +0000 Subject: [PATCH 114/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ede93b7..62e3c78 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.0", @@ -118,4 +119,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From ef1c1b162f5a241b27c2cd501d31a6aa168ea4aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 19:25:51 +0000 Subject: [PATCH 115/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e4ff49c..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";function t(t,e){return"generic"===t?function(r){var n,t;for(n=[],t=0;t[ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tif ( dtype === 'generic' ) {\n\t\treturn generic( size );\n\t}\n\tif ( dtype === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Fills an array-like object with zeros.\n*\n* @private\n* @param {(Array|TypedArray|Buffer)} v - array-like object to fill\n* @returns {(Array|TypedArray|Buffer)} input value\n*\n* @example\n* var arr = zeros( new Array( 2 ) );\n* // returns [ 0, 0 ]\n*/\nfunction zeros( v ) {\n\tvar i;\n\tfor ( i = 0; i < v.length; i++ ) {\n\t\tv[ i ] = 0;\n\t}\n\treturn v;\n}\n\n\n// EXPORTS //\n\nexport default zeros;\n"],"names":["buffer","dtype","size","buf","i","push","generic","v","length","zeros","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;kMAwFA,SAASA,EAAQC,EAAOC,GACvB,MAAe,YAAVD,EArDN,SAAkBC,GACjB,IAAIC,EACAC,EAGJ,IADAD,EAAM,GACAC,EAAI,EAAGA,EAAIF,EAAME,IACtBD,EAAIE,KAAM,GAEX,OAAOF,CACR,CA6CSG,CAASJ,GAEF,WAAVD,EAtCN,SAAiBC,GAChB,OCtBD,SAAgBK,GACf,IAAIH,EACJ,IAAMA,EAAI,EAAGA,EAAIG,EAAEC,OAAQJ,IAC1BG,EAAGH,GAAM,EAEV,OAAOG,CACR,CDgBQE,CAAOC,EAAaR,GAC5B,CAqCSS,CAAQT,GA3BjB,SAAqBD,EAAOC,GAC3B,IAAIU,EAAOC,EAAaZ,GACxB,OAAKW,EACG,IAAIA,EAAMV,GAEX,IACR,CAuBQY,CAAYb,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 35f101c..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3aa5dd1052425b574aaffac6aa2951c11c7a8b18 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Dec 2025 19:26:11 +0000 Subject: [PATCH 116/154] 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 | 253 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 90 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 44 files changed, 4866 insertions(+), 4615 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) 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 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # 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 + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2e2436b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 2d815e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1b999cc --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a9e63bb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;ydAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index 62e3c78..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "github:stdlib-js/array-base-fill#main", - "@stdlib/array-base-zeros": "^0.2.2", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.0", - "@stdlib/array-complex128": "^0.3.0", - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -114,9 +31,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..ec9884f --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 36770b4c95ca19467f29d94c1e367ec1f790bad7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 06:45:13 +0000 Subject: [PATCH 117/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 39a377d..85fa4a8 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.0", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.1", @@ -117,4 +118,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a62d84e919d6eefd6f1060f48b65f16266f8908d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:42:38 +0000 Subject: [PATCH 118/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1b999cc..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a9e63bb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;ydAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ec9884f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3c9f238e1935e82cc64b52875f0d9ce985d554af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:42:55 +0000 Subject: [PATCH 119/154] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 253 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 89 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 44 files changed, 4866 insertions(+), 4714 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) 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 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2e2436b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 2d815e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..bb0abd2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a9e63bb --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;ydAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index 85fa4a8..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "github:stdlib-js/array-base-fill#main", - "@stdlib/array-base-zeros": "^0.2.2", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.3.0", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.0", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.1", - "@stdlib/array-complex128": "^0.3.1", - "@stdlib/array-complex64": "^0.3.1", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.4.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,4 +35,4 @@ "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..ec9884f --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 9335e75afddcdb764713cad11cf6c25e481172ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Feb 2026 03:01:30 +0000 Subject: [PATCH 120/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3f0b3af..23c077e 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/buffer-alloc-unsafe": "^0.2.2", "@stdlib/ndarray-base-buffer-ctors": "^0.4.0", "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.0", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-bool": "^0.1.1", @@ -117,4 +118,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 225ff3f1962343625a8c572ba9be91e8b0e1005d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Feb 2026 04:15:53 +0000 Subject: [PATCH 121/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bb0abd2..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.3.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a9e63bb..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;ydAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ec9884f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6e9df1de97c402c9927461632d898e231c77d21a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Feb 2026 04:16:21 +0000 Subject: [PATCH 122/154] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 253 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 89 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4866 insertions(+), 4715 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ccc806d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-02T02:29:58.265Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2e2436b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 2d815e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a9dff9d --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.0-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..53588c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index 23c077e..afa85b2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.0", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "^0.1.0", - "@stdlib/array-base-zeros": "^0.2.2", - "@stdlib/buffer-alloc-unsafe": "^0.2.2", - "@stdlib/ndarray-base-buffer-ctors": "^0.4.0", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.0", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.1", - "@stdlib/array-complex128": "^0.3.1", - "@stdlib/array-complex64": "^0.3.1", - "@stdlib/array-float32": "^0.2.2", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-int16": "^0.2.2", - "@stdlib/array-int32": "^0.2.2", - "@stdlib/array-int8": "^0.2.2", - "@stdlib/array-uint16": "^0.2.2", - "@stdlib/array-uint32": "^0.2.2", - "@stdlib/array-uint8": "^0.2.2", - "@stdlib/array-uint8c": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-booleanarray": "^0.0.2", - "@stdlib/assert-is-buffer": "^0.2.2", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-complex128array": "^0.2.2", - "@stdlib/assert-is-complex64array": "^0.2.2", - "@stdlib/assert-is-float32array": "^0.2.2", - "@stdlib/assert-is-float64array": "^0.2.2", - "@stdlib/assert-is-int16array": "^0.2.2", - "@stdlib/assert-is-int32array": "^0.2.2", - "@stdlib/assert-is-int8array": "^0.2.2", - "@stdlib/assert-is-uint16array": "^0.2.2", - "@stdlib/assert-is-uint32array": "^0.2.2", - "@stdlib/assert-is-uint8array": "^0.2.2", - "@stdlib/assert-is-uint8clampedarray": "^0.2.2", - "@stdlib/buffer-from-array": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-dtypes": "^0.4.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,4 +35,4 @@ "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..bbaa254 --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From a2d7d56335d74bcc76b94ff2bab5f7e51ce0fceb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 23:14:58 +0000 Subject: [PATCH 123/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7528fdb..7fa4beb 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/buffer-alloc-unsafe": "^0.2.3", "@stdlib/ndarray-base-buffer-ctors": "^0.4.0", "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-bool": "^0.1.2", @@ -117,4 +118,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 5f9270ce90f2e2f7cb50e87bb394d66e358fd1b7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:04:36 +0000 Subject: [PATCH 124/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a9dff9d..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.0-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 53588c3..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index bbaa254..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fb2f8d84073c873f1880644aa04e8c11592307c1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:05:02 +0000 Subject: [PATCH 125/154] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 253 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 89 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 44 files changed, 4866 insertions(+), 4707 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) 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 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2e2436b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 2d815e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..11439b2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.0-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..53588c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index 7fa4beb..c37f3b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "^0.1.0", - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-buffer-ctors": "^0.4.0", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-booleanarray": "^0.0.3", - "@stdlib/assert-is-buffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex128array": "^0.2.3", - "@stdlib/assert-is-complex64array": "^0.2.3", - "@stdlib/assert-is-float32array": "^0.2.3", - "@stdlib/assert-is-float64array": "^0.2.3", - "@stdlib/assert-is-int16array": "^0.2.3", - "@stdlib/assert-is-int32array": "^0.2.3", - "@stdlib/assert-is-int8array": "^0.2.3", - "@stdlib/assert-is-uint16array": "^0.2.3", - "@stdlib/assert-is-uint32array": "^0.2.3", - "@stdlib/assert-is-uint8array": "^0.2.3", - "@stdlib/assert-is-uint8clampedarray": "^0.2.3", - "@stdlib/buffer-from-array": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-dtypes": "^0.4.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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,4 +35,4 @@ "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..5749ea5 --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 02255f29caa95f7b58ddf8c282f003f704fe2bc0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:34:41 +0000 Subject: [PATCH 126/154] Update README.md for ESM bundle v0.3.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c7b9aab..7ae1b2e 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@esm/index.mjs'; +import buffer from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer@v0.3.1-esm/index.mjs'; ``` #### buffer( dtype, size ) @@ -102,7 +102,7 @@ var buf = buffer( 'float', 3 ); - - - - From 42b061ae48353205e5b345a67af7e104258a289c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 03:14:30 +0000 Subject: [PATCH 130/154] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 253 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 89 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4866 insertions(+), 4708 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3a905c9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-09T01:51:08.913Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2e2436b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 2d815e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..698648a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..53588c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index e075b0c..c37f3b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "^0.1.1", - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-buffer-ctors": "^0.4.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-booleanarray": "^0.0.3", - "@stdlib/assert-is-buffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex128array": "^0.2.3", - "@stdlib/assert-is-complex64array": "^0.2.3", - "@stdlib/assert-is-float32array": "^0.2.3", - "@stdlib/assert-is-float64array": "^0.2.3", - "@stdlib/assert-is-int16array": "^0.2.3", - "@stdlib/assert-is-int32array": "^0.2.3", - "@stdlib/assert-is-int8array": "^0.2.3", - "@stdlib/assert-is-uint16array": "^0.2.3", - "@stdlib/assert-is-uint32array": "^0.2.3", - "@stdlib/assert-is-uint8array": "^0.2.3", - "@stdlib/assert-is-uint8clampedarray": "^0.2.3", - "@stdlib/buffer-from-array": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-dtypes": "^0.4.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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,4 +35,4 @@ "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..c24ac4f --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From daa68e250d3f5840bdfd8a9c9f3b5e50d10f719a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Mar 2026 03:35:47 +0000 Subject: [PATCH 131/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3cc9963..e075b0c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/buffer-alloc-unsafe": "^0.2.3", "@stdlib/ndarray-base-buffer-ctors": "^0.4.1", "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-bool": "^0.1.2", @@ -117,4 +118,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 28ab99a730d4c6e14537292217c90883c6d5ead2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Mar 2026 05:35:15 +0000 Subject: [PATCH 132/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 698648a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 53588c3..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c24ac4f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 08bfc61f7b68abe105c413d26e332ca9605df438 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Mar 2026 05:35:35 +0000 Subject: [PATCH 133/154] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 253 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 89 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4866 insertions(+), 4708 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index b8a5836..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-02T02:32:43.667Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2e2436b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 2d815e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..698648a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..53588c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index e075b0c..c37f3b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "^0.1.1", - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-buffer-ctors": "^0.4.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-booleanarray": "^0.0.3", - "@stdlib/assert-is-buffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex128array": "^0.2.3", - "@stdlib/assert-is-complex64array": "^0.2.3", - "@stdlib/assert-is-float32array": "^0.2.3", - "@stdlib/assert-is-float64array": "^0.2.3", - "@stdlib/assert-is-int16array": "^0.2.3", - "@stdlib/assert-is-int32array": "^0.2.3", - "@stdlib/assert-is-int8array": "^0.2.3", - "@stdlib/assert-is-uint16array": "^0.2.3", - "@stdlib/assert-is-uint32array": "^0.2.3", - "@stdlib/assert-is-uint8array": "^0.2.3", - "@stdlib/assert-is-uint8clampedarray": "^0.2.3", - "@stdlib/buffer-from-array": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-dtypes": "^0.4.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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,4 +35,4 @@ "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..c24ac4f --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From d0cf75a7646f47eca2b0a54a575be273f5cc7604 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 02:09:18 +0000 Subject: [PATCH 134/154] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3cc9963..e075b0c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/buffer-alloc-unsafe": "^0.2.3", "@stdlib/ndarray-base-buffer-ctors": "^0.4.1", "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.4.3" + "@stdlib/types": "^0.4.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-bool": "^0.1.2", @@ -117,4 +118,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cca0b1e3e4ebabce2669f2e314f560fa0c0ab72e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 03:51:54 +0000 Subject: [PATCH 135/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 698648a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 53588c3..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c24ac4f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0cbc0032aa5b4145e852166ffa79c275cb486775 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Mar 2026 03:52:21 +0000 Subject: [PATCH 136/154] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 253 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 295 -- benchmark/benchmark.length.js | 134 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 89 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4866 insertions(+), 4708 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 74991bf..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-16T01:41:47.238Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 95cad87..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,295 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( pkg+':dtype=binary', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=bool', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=complex128', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float64', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=float32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=generic', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=int8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint16', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint32', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':dtype=uint8c', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 4654d36..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,134 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( pkg+':len='+len+',dtype=binary', f ); - - f = createBenchmark( 'bool', len ); - bench( pkg+':len='+len+',dtype=bool', f ); - - f = createBenchmark( 'complex64', len ); - bench( pkg+':len='+len+',dtype=complex64', f ); - - f = createBenchmark( 'complex128', len ); - bench( pkg+':len='+len+',dtype=complex128', f ); - - f = createBenchmark( 'float64', len ); - bench( pkg+':len='+len+',dtype=float64', f ); - - f = createBenchmark( 'float32', len ); - bench( pkg+':len='+len+',dtype=float32', f ); - - f = createBenchmark( 'generic', len ); - bench( pkg+':len='+len+',dtype=generic', f ); - - f = createBenchmark( 'int16', len ); - bench( pkg+':len='+len+',dtype=int16', f ); - - f = createBenchmark( 'int32', len ); - bench( pkg+':len='+len+',dtype=int32', f ); - - f = createBenchmark( 'int8', len ); - bench( pkg+':len='+len+',dtype=int8', f ); - - f = createBenchmark( 'uint16', len ); - bench( pkg+':len='+len+',dtype=uint16', f ); - - f = createBenchmark( 'uint32', len ); - bench( pkg+':len='+len+',dtype=uint32', f ); - - f = createBenchmark( 'uint8', len ); - bench( pkg+':len='+len+',dtype=uint8', f ); - - f = createBenchmark( 'uint8c', len ); - bench( pkg+':len='+len+',dtype=uint8c', f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2e2436b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 2d815e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..698648a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..53588c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index e075b0c..c37f3b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "^0.1.1", - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-buffer-ctors": "^0.4.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-booleanarray": "^0.0.3", - "@stdlib/assert-is-buffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex128array": "^0.2.3", - "@stdlib/assert-is-complex64array": "^0.2.3", - "@stdlib/assert-is-float32array": "^0.2.3", - "@stdlib/assert-is-float64array": "^0.2.3", - "@stdlib/assert-is-int16array": "^0.2.3", - "@stdlib/assert-is-int32array": "^0.2.3", - "@stdlib/assert-is-int8array": "^0.2.3", - "@stdlib/assert-is-uint16array": "^0.2.3", - "@stdlib/assert-is-uint32array": "^0.2.3", - "@stdlib/assert-is-uint8array": "^0.2.3", - "@stdlib/assert-is-uint8clampedarray": "^0.2.3", - "@stdlib/buffer-from-array": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-dtypes": "^0.4.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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -118,4 +35,4 @@ "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..c24ac4f --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From cdbb2d607360b6aeddd52e3bcff022108c39b2f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 18 Mar 2026 18:06:13 +0000 Subject: [PATCH 137/154] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c7ccd33..ea99a7d 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "@stdlib/buffer-from-array": "^0.2.3", "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "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 fcafbf46bbdfb542b0abafa1ba93d3ca5a060f7d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 18 Mar 2026 18:06:35 +0000 Subject: [PATCH 138/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 698648a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 53588c3..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c24ac4f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 00b0d66c327585d74c6fd62f436cc7971e6bb8a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 18 Mar 2026 18:07:22 +0000 Subject: [PATCH 139/154] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 287 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 296 -- benchmark/benchmark.length.js | 135 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 44 files changed, 4865 insertions(+), 4742 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) 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 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 50938ae..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,296 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:dtype=binary', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 01455bc..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( format( '%s:len=%d,dtype=binary', pkg, len ), f ); - - f = createBenchmark( 'bool', len ); - bench( format( '%s:len=%d,dtype=bool', pkg, len ), f ); - - f = createBenchmark( 'complex64', len ); - bench( format( '%s:len=%d,dtype=complex64', pkg, len ), f ); - - f = createBenchmark( 'complex128', len ); - bench( format( '%s:len=%d,dtype=complex128', pkg, len ), f ); - - f = createBenchmark( 'float64', len ); - bench( format( '%s:len=%d,dtype=float64', pkg, len ), f ); - - f = createBenchmark( 'float32', len ); - bench( format( '%s:len=%d,dtype=float32', pkg, len ), f ); - - f = createBenchmark( 'generic', len ); - bench( format( '%s:len=%d,dtype=generic', pkg, len ), f ); - - f = createBenchmark( 'int16', len ); - bench( format( '%s:len=%d,dtype=int16', pkg, len ), f ); - - f = createBenchmark( 'int32', len ); - bench( format( '%s:len=%d,dtype=int32', pkg, len ), f ); - - f = createBenchmark( 'int8', len ); - bench( format( '%s:len=%d,dtype=int8', pkg, len ), f ); - - f = createBenchmark( 'uint16', len ); - bench( format( '%s:len=%d,dtype=uint16', pkg, len ), f ); - - f = createBenchmark( 'uint32', len ); - bench( format( '%s:len=%d,dtype=uint32', pkg, len ), f ); - - f = createBenchmark( 'uint8', len ); - bench( format( '%s:len=%d,dtype=uint8', pkg, len ), f ); - - f = createBenchmark( 'uint8c', len ); - bench( format( '%s:len=%d,dtype=uint8c', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2e2436b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 2d815e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..698648a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..53588c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index ea99a7d..c37f3b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "^0.1.1", - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-buffer-ctors": "^0.4.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.4.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-booleanarray": "^0.0.3", - "@stdlib/assert-is-buffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex128array": "^0.2.3", - "@stdlib/assert-is-complex64array": "^0.2.3", - "@stdlib/assert-is-float32array": "^0.2.3", - "@stdlib/assert-is-float64array": "^0.2.3", - "@stdlib/assert-is-int16array": "^0.2.3", - "@stdlib/assert-is-int32array": "^0.2.3", - "@stdlib/assert-is-int8array": "^0.2.3", - "@stdlib/assert-is-uint16array": "^0.2.3", - "@stdlib/assert-is-uint32array": "^0.2.3", - "@stdlib/assert-is-uint8array": "^0.2.3", - "@stdlib/assert-is-uint8clampedarray": "^0.2.3", - "@stdlib/buffer-from-array": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c24ac4f --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 41d5318c387735d38770ed768e4bea4b283afa2e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Apr 2026 03:48:18 +0000 Subject: [PATCH 140/154] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c7ccd33..ea99a7d 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "@stdlib/buffer-from-array": "^0.2.3", "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "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 85bf3382f0250c43bc52125cdaa26520b1f5b443 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Apr 2026 03:59:09 +0000 Subject: [PATCH 141/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 698648a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 53588c3..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c24ac4f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0d154da079fb56166ca28b502360aedf65da45e9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Apr 2026 03:59:33 +0000 Subject: [PATCH 142/154] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 287 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 296 -- benchmark/benchmark.length.js | 135 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4865 insertions(+), 4754 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6223280..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-09T03:34:40.054Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 50938ae..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,296 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:dtype=binary', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 01455bc..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( format( '%s:len=%d,dtype=binary', pkg, len ), f ); - - f = createBenchmark( 'bool', len ); - bench( format( '%s:len=%d,dtype=bool', pkg, len ), f ); - - f = createBenchmark( 'complex64', len ); - bench( format( '%s:len=%d,dtype=complex64', pkg, len ), f ); - - f = createBenchmark( 'complex128', len ); - bench( format( '%s:len=%d,dtype=complex128', pkg, len ), f ); - - f = createBenchmark( 'float64', len ); - bench( format( '%s:len=%d,dtype=float64', pkg, len ), f ); - - f = createBenchmark( 'float32', len ); - bench( format( '%s:len=%d,dtype=float32', pkg, len ), f ); - - f = createBenchmark( 'generic', len ); - bench( format( '%s:len=%d,dtype=generic', pkg, len ), f ); - - f = createBenchmark( 'int16', len ); - bench( format( '%s:len=%d,dtype=int16', pkg, len ), f ); - - f = createBenchmark( 'int32', len ); - bench( format( '%s:len=%d,dtype=int32', pkg, len ), f ); - - f = createBenchmark( 'int8', len ); - bench( format( '%s:len=%d,dtype=int8', pkg, len ), f ); - - f = createBenchmark( 'uint16', len ); - bench( format( '%s:len=%d,dtype=uint16', pkg, len ), f ); - - f = createBenchmark( 'uint32', len ); - bench( format( '%s:len=%d,dtype=uint32', pkg, len ), f ); - - f = createBenchmark( 'uint8', len ); - bench( format( '%s:len=%d,dtype=uint8', pkg, len ), f ); - - f = createBenchmark( 'uint8c', len ); - bench( format( '%s:len=%d,dtype=uint8c', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2e2436b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 2d815e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..698648a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..53588c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index ea99a7d..c37f3b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "^0.1.1", - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-buffer-ctors": "^0.4.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.4.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-booleanarray": "^0.0.3", - "@stdlib/assert-is-buffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex128array": "^0.2.3", - "@stdlib/assert-is-complex64array": "^0.2.3", - "@stdlib/assert-is-float32array": "^0.2.3", - "@stdlib/assert-is-float64array": "^0.2.3", - "@stdlib/assert-is-int16array": "^0.2.3", - "@stdlib/assert-is-int32array": "^0.2.3", - "@stdlib/assert-is-int8array": "^0.2.3", - "@stdlib/assert-is-uint16array": "^0.2.3", - "@stdlib/assert-is-uint32array": "^0.2.3", - "@stdlib/assert-is-uint8array": "^0.2.3", - "@stdlib/assert-is-uint8clampedarray": "^0.2.3", - "@stdlib/buffer-from-array": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c24ac4f --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 8e392af8f0810a0da7026c7b269a74959103d15a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 17 May 2026 03:47:25 +0000 Subject: [PATCH 143/154] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c7ccd33..ea99a7d 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "@stdlib/buffer-from-array": "^0.2.3", "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "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 e55624bc032ae5e7ce6588f560dd8a0c67a63dbd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 17 May 2026 03:58:00 +0000 Subject: [PATCH 144/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 698648a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 53588c3..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c24ac4f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6e2cee655c32f7b0f4ee3ec16335a699b95fdc5a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 17 May 2026 03:58:19 +0000 Subject: [PATCH 145/154] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 287 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 296 -- benchmark/benchmark.length.js | 135 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4865 insertions(+), 4759 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4a3c4a3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-17T03:38:58.945Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 50938ae..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,296 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:dtype=binary', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 01455bc..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( format( '%s:len=%d,dtype=binary', pkg, len ), f ); - - f = createBenchmark( 'bool', len ); - bench( format( '%s:len=%d,dtype=bool', pkg, len ), f ); - - f = createBenchmark( 'complex64', len ); - bench( format( '%s:len=%d,dtype=complex64', pkg, len ), f ); - - f = createBenchmark( 'complex128', len ); - bench( format( '%s:len=%d,dtype=complex128', pkg, len ), f ); - - f = createBenchmark( 'float64', len ); - bench( format( '%s:len=%d,dtype=float64', pkg, len ), f ); - - f = createBenchmark( 'float32', len ); - bench( format( '%s:len=%d,dtype=float32', pkg, len ), f ); - - f = createBenchmark( 'generic', len ); - bench( format( '%s:len=%d,dtype=generic', pkg, len ), f ); - - f = createBenchmark( 'int16', len ); - bench( format( '%s:len=%d,dtype=int16', pkg, len ), f ); - - f = createBenchmark( 'int32', len ); - bench( format( '%s:len=%d,dtype=int32', pkg, len ), f ); - - f = createBenchmark( 'int8', len ); - bench( format( '%s:len=%d,dtype=int8', pkg, len ), f ); - - f = createBenchmark( 'uint16', len ); - bench( format( '%s:len=%d,dtype=uint16', pkg, len ), f ); - - f = createBenchmark( 'uint32', len ); - bench( format( '%s:len=%d,dtype=uint32', pkg, len ), f ); - - f = createBenchmark( 'uint8', len ); - bench( format( '%s:len=%d,dtype=uint8', pkg, len ), f ); - - f = createBenchmark( 'uint8c', len ); - bench( format( '%s:len=%d,dtype=uint8c', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2e2436b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 2d815e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..698648a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..53588c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index ea99a7d..c37f3b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "^0.1.1", - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-buffer-ctors": "^0.4.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.4.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-booleanarray": "^0.0.3", - "@stdlib/assert-is-buffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex128array": "^0.2.3", - "@stdlib/assert-is-complex64array": "^0.2.3", - "@stdlib/assert-is-float32array": "^0.2.3", - "@stdlib/assert-is-float64array": "^0.2.3", - "@stdlib/assert-is-int16array": "^0.2.3", - "@stdlib/assert-is-int32array": "^0.2.3", - "@stdlib/assert-is-int8array": "^0.2.3", - "@stdlib/assert-is-uint16array": "^0.2.3", - "@stdlib/assert-is-uint32array": "^0.2.3", - "@stdlib/assert-is-uint8array": "^0.2.3", - "@stdlib/assert-is-uint8clampedarray": "^0.2.3", - "@stdlib/buffer-from-array": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c24ac4f --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 44840e5857a9663a4ddb965aef3887f8d3c99c4a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 03:51:13 +0000 Subject: [PATCH 146/154] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c7ccd33..ea99a7d 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "@stdlib/buffer-from-array": "^0.2.3", "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "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 2c3447aec90654b0c3b1b638af08903437bd4445 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 04:13:31 +0000 Subject: [PATCH 147/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 698648a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 53588c3..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c24ac4f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From aad0268d644b64cca184d28caf581268932d79f4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 May 2026 04:13:55 +0000 Subject: [PATCH 148/154] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 287 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 296 -- benchmark/benchmark.length.js | 135 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4865 insertions(+), 4772 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d927a5e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-20T03:37:30.656Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 50938ae..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,296 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:dtype=binary', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 01455bc..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( format( '%s:len=%d,dtype=binary', pkg, len ), f ); - - f = createBenchmark( 'bool', len ); - bench( format( '%s:len=%d,dtype=bool', pkg, len ), f ); - - f = createBenchmark( 'complex64', len ); - bench( format( '%s:len=%d,dtype=complex64', pkg, len ), f ); - - f = createBenchmark( 'complex128', len ); - bench( format( '%s:len=%d,dtype=complex128', pkg, len ), f ); - - f = createBenchmark( 'float64', len ); - bench( format( '%s:len=%d,dtype=float64', pkg, len ), f ); - - f = createBenchmark( 'float32', len ); - bench( format( '%s:len=%d,dtype=float32', pkg, len ), f ); - - f = createBenchmark( 'generic', len ); - bench( format( '%s:len=%d,dtype=generic', pkg, len ), f ); - - f = createBenchmark( 'int16', len ); - bench( format( '%s:len=%d,dtype=int16', pkg, len ), f ); - - f = createBenchmark( 'int32', len ); - bench( format( '%s:len=%d,dtype=int32', pkg, len ), f ); - - f = createBenchmark( 'int8', len ); - bench( format( '%s:len=%d,dtype=int8', pkg, len ), f ); - - f = createBenchmark( 'uint16', len ); - bench( format( '%s:len=%d,dtype=uint16', pkg, len ), f ); - - f = createBenchmark( 'uint32', len ); - bench( format( '%s:len=%d,dtype=uint32', pkg, len ), f ); - - f = createBenchmark( 'uint8', len ); - bench( format( '%s:len=%d,dtype=uint8', pkg, len ), f ); - - f = createBenchmark( 'uint8c', len ); - bench( format( '%s:len=%d,dtype=uint8c', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 2e2436b..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 2d815e3..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..698648a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..53588c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index ea99a7d..c37f3b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "^0.1.1", - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-buffer-ctors": "^0.4.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.4.3" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-booleanarray": "^0.0.3", - "@stdlib/assert-is-buffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex128array": "^0.2.3", - "@stdlib/assert-is-complex64array": "^0.2.3", - "@stdlib/assert-is-float32array": "^0.2.3", - "@stdlib/assert-is-float64array": "^0.2.3", - "@stdlib/assert-is-int16array": "^0.2.3", - "@stdlib/assert-is-int32array": "^0.2.3", - "@stdlib/assert-is-int8array": "^0.2.3", - "@stdlib/assert-is-uint16array": "^0.2.3", - "@stdlib/assert-is-uint32array": "^0.2.3", - "@stdlib/assert-is-uint8array": "^0.2.3", - "@stdlib/assert-is-uint8clampedarray": "^0.2.3", - "@stdlib/buffer-from-array": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c24ac4f --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 35a4b289933727c891b2df22485a9e0fac3f82a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 03:25:13 +0000 Subject: [PATCH 149/154] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3846c26..ffa152c 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "@stdlib/buffer-from-array": "^0.2.3", "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "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 e43a4c164fded57004a0d998bf72850f8781ad1e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 03:27:29 +0000 Subject: [PATCH 150/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 698648a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 53588c3..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c24ac4f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 59a32367ce2d932a6320deb67754bb6b7569877b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 03:27:48 +0000 Subject: [PATCH 151/154] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 287 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 296 -- benchmark/benchmark.length.js | 135 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4865 insertions(+), 4772 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 59f812c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-07-01T03:23:45.881Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 50938ae..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,296 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:dtype=binary', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 01455bc..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( format( '%s:len=%d,dtype=binary', pkg, len ), f ); - - f = createBenchmark( 'bool', len ); - bench( format( '%s:len=%d,dtype=bool', pkg, len ), f ); - - f = createBenchmark( 'complex64', len ); - bench( format( '%s:len=%d,dtype=complex64', pkg, len ), f ); - - f = createBenchmark( 'complex128', len ); - bench( format( '%s:len=%d,dtype=complex128', pkg, len ), f ); - - f = createBenchmark( 'float64', len ); - bench( format( '%s:len=%d,dtype=float64', pkg, len ), f ); - - f = createBenchmark( 'float32', len ); - bench( format( '%s:len=%d,dtype=float32', pkg, len ), f ); - - f = createBenchmark( 'generic', len ); - bench( format( '%s:len=%d,dtype=generic', pkg, len ), f ); - - f = createBenchmark( 'int16', len ); - bench( format( '%s:len=%d,dtype=int16', pkg, len ), f ); - - f = createBenchmark( 'int32', len ); - bench( format( '%s:len=%d,dtype=int32', pkg, len ), f ); - - f = createBenchmark( 'int8', len ); - bench( format( '%s:len=%d,dtype=int8', pkg, len ), f ); - - f = createBenchmark( 'uint16', len ); - bench( format( '%s:len=%d,dtype=uint16', pkg, len ), f ); - - f = createBenchmark( 'uint32', len ); - bench( format( '%s:len=%d,dtype=uint32', pkg, len ), f ); - - f = createBenchmark( 'uint8', len ); - bench( format( '%s:len=%d,dtype=uint8', pkg, len ), f ); - - f = createBenchmark( 'uint8c', len ); - bench( format( '%s:len=%d,dtype=uint8c', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 78db766..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){try{return r||e((r={exports:{}}).exports,r),r.exports}catch(u){throw (r=0, u)}};};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 4a7dce9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..698648a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..53588c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index ffa152c..c37f3b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "^0.1.1", - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-buffer-ctors": "^0.4.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.5.1" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-booleanarray": "^0.0.3", - "@stdlib/assert-is-buffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex128array": "^0.2.3", - "@stdlib/assert-is-complex64array": "^0.2.3", - "@stdlib/assert-is-float32array": "^0.2.3", - "@stdlib/assert-is-float64array": "^0.2.3", - "@stdlib/assert-is-int16array": "^0.2.3", - "@stdlib/assert-is-int32array": "^0.2.3", - "@stdlib/assert-is-int8array": "^0.2.3", - "@stdlib/assert-is-uint16array": "^0.2.3", - "@stdlib/assert-is-uint32array": "^0.2.3", - "@stdlib/assert-is-uint8array": "^0.2.3", - "@stdlib/assert-is-uint8clampedarray": "^0.2.3", - "@stdlib/buffer-from-array": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c24ac4f --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -}); From 4a42a13d3a5180fc96e2fcc4d9447c9e205638a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 03:20:47 +0000 Subject: [PATCH 152/154] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3846c26..ffa152c 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "@stdlib/buffer-from-array": "^0.2.3", "@stdlib/math-base-special-pow": "^0.3.1", "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "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 7c794bdf7d0c0567416a7e1316c101af839fb9af Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 03:41:48 +0000 Subject: [PATCH 153/154] Remove files --- index.d.ts | 49 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4896 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 7cd6168..0000000 --- a/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// -/// - -import { Buffer } from 'buffer'; -import { TypedArray, ComplexTypedArray, BooleanTypedArray } from '@stdlib/types/array'; -import { DataType } from '@stdlib/types/ndarray'; - -/** -* Array or typed array. -*/ -type ArrayOrBufferOrTypedArray = Array | TypedArray | ComplexTypedArray | BooleanTypedArray | Buffer | null; - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param dtype - data type -* @param size - buffer size -* @returns data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -declare function buffer( dtype: DataType, size: number ): ArrayOrBufferOrTypedArray; - - -// EXPORTS // - -export = buffer; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 698648a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 53588c3..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c24ac4f..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cf22a69e3195b1e9bf39fbcf13fab7ca17763499 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 03:42:18 +0000 Subject: [PATCH 154/154] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 205 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 287 -- CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 296 -- benchmark/benchmark.length.js | 135 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 25 - docs/types/test.ts | 57 - 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 | 87 - package.json | 87 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 184 - 45 files changed, 4865 insertions(+), 4773 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/benchmark.length.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 (94%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1619941..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-19T03:16:00.208Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 5312aa2..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d152c02..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ea17972..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: '18 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -156,7 +147,7 @@ for ( i = 0; i < DTYPES.length; i++ ) { ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. @@ -219,7 +210,7 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-base-buffer/main/LICENSE -[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes +[@stdlib/ndarray/dtypes]: https://github.com/stdlib-js/ndarray-dtypes/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 50938ae..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,296 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:dtype=binary', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'binary', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=bool', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'bool', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=complex128', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'complex128', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float64', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float64', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=float32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'float32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=generic', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'generic', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=int8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'int8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint16', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint16', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint32', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint32', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s:dtype=uint8c', pkg ), function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( 'uint8c', 10 ); - if ( out.length !== 10 ) { - b.fail( 'should have length 10' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/benchmark.length.js b/benchmark/benchmark.length.js deleted file mode 100644 index 01455bc..0000000 --- a/benchmark/benchmark.length.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var buffer = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {string} dtype - data type -* @param {PositiveInteger} len - buffer length -* @returns {Function} benchmark function -*/ -function createBenchmark( dtype, len ) { - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = buffer( dtype, len ); - if ( out.length !== len ) { - b.fail( 'unexpected length' ); - } - } - b.toc(); - if ( !isCollection( out ) ) { - b.fail( 'should return an array-like object' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - - f = createBenchmark( 'binary', len ); - bench( format( '%s:len=%d,dtype=binary', pkg, len ), f ); - - f = createBenchmark( 'bool', len ); - bench( format( '%s:len=%d,dtype=bool', pkg, len ), f ); - - f = createBenchmark( 'complex64', len ); - bench( format( '%s:len=%d,dtype=complex64', pkg, len ), f ); - - f = createBenchmark( 'complex128', len ); - bench( format( '%s:len=%d,dtype=complex128', pkg, len ), f ); - - f = createBenchmark( 'float64', len ); - bench( format( '%s:len=%d,dtype=float64', pkg, len ), f ); - - f = createBenchmark( 'float32', len ); - bench( format( '%s:len=%d,dtype=float32', pkg, len ), f ); - - f = createBenchmark( 'generic', len ); - bench( format( '%s:len=%d,dtype=generic', pkg, len ), f ); - - f = createBenchmark( 'int16', len ); - bench( format( '%s:len=%d,dtype=int16', pkg, len ), f ); - - f = createBenchmark( 'int32', len ); - bench( format( '%s:len=%d,dtype=int32', pkg, len ), f ); - - f = createBenchmark( 'int8', len ); - bench( format( '%s:len=%d,dtype=int8', pkg, len ), f ); - - f = createBenchmark( 'uint16', len ); - bench( format( '%s:len=%d,dtype=uint16', pkg, len ), f ); - - f = createBenchmark( 'uint32', len ); - bench( format( '%s:len=%d,dtype=uint32', pkg, len ), f ); - - f = createBenchmark( 'uint8', len ); - bench( format( '%s:len=%d,dtype=uint8', pkg, len ), f ); - - f = createBenchmark( 'uint8c', len ); - bench( format( '%s:len=%d,dtype=uint8c', pkg, len ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2806aa0..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer" -%% click B href "https://github.com/stdlib-js/ndarray-base-buffer/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-buffer/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-buffer/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-buffer/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-buffer/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/buffer -[production-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-buffer/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-buffer/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-buffer/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 faf6f6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import buffer from '../docs/types/index'; -export = buffer; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 78db766..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(e,r){return function(){try{return r||e((r={exports:{}}).exports,r),r.exports}catch(u){throw (r=0, u)}};};var t=i(function(p,n){ -var a=require('@stdlib/ndarray-base-dtype-resolve-str/dist'),f=require('@stdlib/ndarray-base-buffer-ctors/dist'),o=require('@stdlib/buffer-alloc-unsafe/dist'),v=require('@stdlib/array-base-zeros/dist'),c=require('@stdlib/array-base-fill/dist');function l(e){return c(o(e),0,0,e)}function s(e,r){var u=f(e);return u?new u(r):null}function q(e,r){var u=a(e);return u==="generic"?v(r):u==="binary"?l(r):s(e,r)}n.exports=q -});var b=t();module.exports=b; -/** @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 4a7dce9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' );\nvar bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' );\nvar allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' );\nvar zeros = require( '@stdlib/array-base-zeros' );\nvar fill = require( '@stdlib/array-base-fill' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nmodule.exports = buffer;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a contiguous linear ndarray data buffer.\n*\n* @module @stdlib/ndarray-base-buffer\n*\n* @example\n* var buffer = require( '@stdlib/ndarray-base-buffer' );\n*\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,wCAAyC,EAC/DC,EAAc,QAAS,mCAAoC,EAC3DC,EAAc,QAAS,6BAA8B,EACrDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAO,QAAS,yBAA0B,EAY9C,SAASC,EAAQC,EAAO,CACvB,OAAOF,EAAMF,EAAaI,CAAK,EAAG,EAAG,EAAGA,CAAK,CAC9C,CAUA,SAASC,EAAYC,EAAOF,EAAO,CAClC,IAAIG,EAAOR,EAAaO,CAAM,EAC9B,OAAKC,EACG,IAAIA,EAAMH,CAAK,EAEhB,IACR,CAgBA,SAASI,EAAQF,EAAOF,EAAO,CAC9B,IAAIK,EAAKX,EAAYQ,CAAM,EAC3B,OAAKG,IAAO,UACJR,EAAOG,CAAK,EAEfK,IAAO,SACJN,EAAQC,CAAK,EAEdC,EAAYC,EAAOF,CAAK,CAChC,CAKAP,EAAO,QAAUW,ICpDjB,IAAIE,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "resolveStr", "bufferCtors", "allocUnsafe", "zeros", "fill", "binary", "size", "typedarray", "dtype", "ctor", "buffer", "dt", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 936a507..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,25 +0,0 @@ - -{{alias}}( dtype, size ) - Returns a contiguous linear ndarray data buffer. - - Parameters - ---------- - dtype: string|DataType - Data type. - - size: integer - Buffer size. - - Returns - ------- - out: Array|TypedArray|Buffer - Contiguous ndarray data buffer. - - Examples - -------- - > var buf = {{alias}}( 'float64', 3 ) - [ 0.0, 0.0, 0.0 ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 381b28c..0000000 --- a/docs/types/test.ts +++ /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. -*/ - -import buffer = require( './index' ); - - -// TESTS // - -// The function returns an array, typed array, buffer, or null... -{ - buffer( 'int32', 20 ); // $ExpectType ArrayOrBufferOrTypedArray - buffer( 'float32', 3 ); // $ExpectType ArrayOrBufferOrTypedArray -} - -// The compiler throws an error if the function is provided a first argument which is not a recognized ndarray data type... -{ - buffer( 'abc', 3 ); // $ExpectError - buffer( 123, 3 ); // $ExpectError - buffer( true, 3 ); // $ExpectError - buffer( false, 3 ); // $ExpectError - buffer( {}, 3 ); // $ExpectError - buffer( [], 3 ); // $ExpectError - buffer( null, 3 ); // $ExpectError - buffer( undefined, 3 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a number... -{ - buffer( 'float64', 'abc' ); // $ExpectError - buffer( 'float64', [] ); // $ExpectError - buffer( 'float64', {} ); // $ExpectError - buffer( 'float64', true ); // $ExpectError - buffer( 'float64', false ); // $ExpectError - buffer( 'float64', null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - buffer(); // $ExpectError - buffer( 'int32' ); // $ExpectError - buffer( 'int32', 3, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index b844436..0000000 --- a/examples/index.js +++ /dev/null @@ -1,31 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 dtypes = require( '@stdlib/ndarray-dtypes' ); -var buffer = require( './../lib' ); - -var DTYPES = dtypes(); - -var buf; -var i; -for ( i = 0; i < DTYPES.length; i++ ) { - buf = buffer( DTYPES[ i ], 10 ); - console.log( buf ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 94% rename from docs/types/index.d.ts rename to index.d.ts index 63e041d..7cd6168 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// /// import { Buffer } from 'buffer'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..698648a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-dtype-resolve-str@v0.3.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-buffer-ctors@v0.4.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/buffer-alloc-unsafe@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zeros@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-fill@v0.1.1-esm/index.mjs";function i(i,d){var m=r(i);return"generic"===m?t(d):"binary"===m?function(r){return n(e(r),0,0,r)}(d):function(r,e){var t=s(r);return t?new t(e):null}(i,d)}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..53588c3 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport resolveStr from '@stdlib/ndarray-base-dtype-resolve-str';\nimport bufferCtors from '@stdlib/ndarray-base-buffer-ctors';\nimport allocUnsafe from '@stdlib/buffer-alloc-unsafe';\nimport zeros from '@stdlib/array-base-zeros';\nimport fill from '@stdlib/array-base-fill';\n\n\n// FUNCTIONS //\n\n/**\n* Returns a zero-filled binary buffer.\n*\n* @private\n* @param {NonNegativeInteger} size - buffer size\n* @returns {Buffer} zero-filled binary buffer\n*/\nfunction binary( size ) {\n\treturn fill( allocUnsafe( size ), 0, 0, size );\n}\n\n/**\n* Returns a typed array.\n*\n* @private\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(TypedArray|null)} typed array\n*/\nfunction typedarray( dtype, size ) {\n\tvar ctor = bufferCtors( dtype );\n\tif ( ctor ) {\n\t\treturn new ctor( size );\n\t}\n\treturn null;\n}\n\n\n// MAIN //\n\n/**\n* Returns a contiguous linear ndarray data buffer.\n*\n* @param {*} dtype - data type\n* @param {NonNegativeInteger} size - buffer size\n* @returns {(Array|TypedArray|Buffer|null)} data buffer\n*\n* @example\n* var buf = buffer( 'float64', 3 );\n* // returns [ 0.0, 0.0, 0.0 ]\n*/\nfunction buffer( dtype, size ) {\n\tvar dt = resolveStr( dtype );\n\tif ( dt === 'generic' ) {\n\t\treturn zeros( size );\n\t}\n\tif ( dt === 'binary' ) {\n\t\treturn binary( size );\n\t}\n\treturn typedarray( dtype, size );\n}\n\n\n// EXPORTS //\n\nexport default buffer;\n"],"names":["buffer","dtype","size","dt","resolveStr","zeros","fill","allocUnsafe","binary","ctor","bufferCtors","typedarray"],"mappings":";;geAwEA,SAASA,EAAQC,EAAOC,GACvB,IAAIC,EAAKC,EAAYH,GACrB,MAAY,YAAPE,EACGE,EAAOH,GAEH,WAAPC,EAvCN,SAAiBD,GAChB,OAAOI,EAAMC,EAAaL,GAAQ,EAAG,EAAGA,EACzC,CAsCSM,CAAQN,GA5BjB,SAAqBD,EAAOC,GAC3B,IAAIO,EAAOC,EAAaT,GACxB,OAAKQ,EACG,IAAIA,EAAMP,GAEX,IACR,CAwBQS,CAAYV,EAAOC,EAC3B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 9befbe6..0000000 --- a/lib/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Create a contiguous linear ndarray data buffer. -* -* @module @stdlib/ndarray-base-buffer -* -* @example -* var buffer = require( '@stdlib/ndarray-base-buffer' ); -* -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 8b65d61..0000000 --- a/lib/main.js +++ /dev/null @@ -1,87 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var resolveStr = require( '@stdlib/ndarray-base-dtype-resolve-str' ); -var bufferCtors = require( '@stdlib/ndarray-base-buffer-ctors' ); -var allocUnsafe = require( '@stdlib/buffer-alloc-unsafe' ); -var zeros = require( '@stdlib/array-base-zeros' ); -var fill = require( '@stdlib/array-base-fill' ); - - -// FUNCTIONS // - -/** -* Returns a zero-filled binary buffer. -* -* @private -* @param {NonNegativeInteger} size - buffer size -* @returns {Buffer} zero-filled binary buffer -*/ -function binary( size ) { - return fill( allocUnsafe( size ), 0, 0, size ); -} - -/** -* Returns a typed array. -* -* @private -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(TypedArray|null)} typed array -*/ -function typedarray( dtype, size ) { - var ctor = bufferCtors( dtype ); - if ( ctor ) { - return new ctor( size ); - } - return null; -} - - -// MAIN // - -/** -* Returns a contiguous linear ndarray data buffer. -* -* @param {*} dtype - data type -* @param {NonNegativeInteger} size - buffer size -* @returns {(Array|TypedArray|Buffer|null)} data buffer -* -* @example -* var buf = buffer( 'float64', 3 ); -* // returns [ 0.0, 0.0, 0.0 ] -*/ -function buffer( dtype, size ) { - var dt = resolveStr( dtype ); - if ( dt === 'generic' ) { - return zeros( size ); - } - if ( dt === 'binary' ) { - return binary( size ); - } - return typedarray( dtype, size ); -} - - -// EXPORTS // - -module.exports = buffer; diff --git a/package.json b/package.json index ffa152c..c37f3b3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.3.1", "description": "Create a contiguous linear ndarray data buffer.", "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,66 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-fill": "^0.1.1", - "@stdlib/array-base-zeros": "^0.2.3", - "@stdlib/buffer-alloc-unsafe": "^0.2.3", - "@stdlib/ndarray-base-buffer-ctors": "^0.4.1", - "@stdlib/ndarray-base-dtype-resolve-str": "^0.3.1", - "@stdlib/types": "^0.5.1" - }, - "devDependencies": { - "@stdlib/array-bool": "^0.1.2", - "@stdlib/array-complex128": "^0.3.2", - "@stdlib/array-complex64": "^0.3.2", - "@stdlib/array-float32": "^0.2.3", - "@stdlib/array-float64": "^0.2.3", - "@stdlib/array-int16": "^0.2.3", - "@stdlib/array-int32": "^0.2.3", - "@stdlib/array-int8": "^0.2.3", - "@stdlib/array-uint16": "^0.2.3", - "@stdlib/array-uint32": "^0.2.3", - "@stdlib/array-uint8": "^0.2.3", - "@stdlib/array-uint8c": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-booleanarray": "^0.0.3", - "@stdlib/assert-is-buffer": "^0.2.3", - "@stdlib/assert-is-collection": "^0.2.3", - "@stdlib/assert-is-complex128array": "^0.2.3", - "@stdlib/assert-is-complex64array": "^0.2.3", - "@stdlib/assert-is-float32array": "^0.2.3", - "@stdlib/assert-is-float64array": "^0.2.3", - "@stdlib/assert-is-int16array": "^0.2.3", - "@stdlib/assert-is-int32array": "^0.2.3", - "@stdlib/assert-is-int8array": "^0.2.3", - "@stdlib/assert-is-uint16array": "^0.2.3", - "@stdlib/assert-is-uint32array": "^0.2.3", - "@stdlib/assert-is-uint8array": "^0.2.3", - "@stdlib/assert-is-uint8clampedarray": "^0.2.3", - "@stdlib/buffer-from-array": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.1", - "@stdlib/ndarray-dtypes": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c24ac4f --- /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 8bcf271..0000000 --- a/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var array2buffer = require( '@stdlib/buffer-from-array' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Float32Array = require( '@stdlib/array-float32' ); -var Int16Array = require( '@stdlib/array-int16' ); -var Int32Array = require( '@stdlib/array-int32' ); -var Int8Array = require( '@stdlib/array-int8' ); -var Uint16Array = require( '@stdlib/array-uint16' ); -var Uint32Array = require( '@stdlib/array-uint32' ); -var Uint8Array = require( '@stdlib/array-uint8' ); -var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var Complex128Array = require( '@stdlib/array-complex128' ); -var BooleanArray = require( '@stdlib/array-bool' ); -var isBuffer = require( '@stdlib/assert-is-buffer' ); -var isArray = require( '@stdlib/assert-is-array' ); -var isFloat64Array = require( '@stdlib/assert-is-float64array' ); -var isFloat32Array = require( '@stdlib/assert-is-float32array' ); -var isInt16Array = require( '@stdlib/assert-is-int16array' ); -var isInt32Array = require( '@stdlib/assert-is-int32array' ); -var isInt8Array = require( '@stdlib/assert-is-int8array' ); -var isUint16Array = require( '@stdlib/assert-is-uint16array' ); -var isUint32Array = require( '@stdlib/assert-is-uint32array' ); -var isUint8Array = require( '@stdlib/assert-is-uint8array' ); -var isUint8ClampedArray = require( '@stdlib/assert-is-uint8clampedarray' ); -var isComplex64Array = require( '@stdlib/assert-is-complex64array' ); -var isComplex128Array = require( '@stdlib/assert-is-complex128array' ); -var isBooleanArray = require( '@stdlib/assert-is-booleanarray' ); -var buffer = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof buffer, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns contiguous ndarray data buffers', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - var j; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]; - expected = [ - [ array2buffer( vals ), isBuffer ], - [ new BooleanArray( vals ), isBooleanArray ], - [ new Complex64Array( vals ), isComplex64Array ], - [ new Complex128Array( vals ), isComplex128Array ], - [ new Float64Array( vals ), isFloat64Array ], - [ new Float32Array( vals ), isFloat32Array ], - [ vals, isArray ], - [ new Int16Array( vals ), isInt16Array ], - [ new Int32Array( vals ), isInt32Array ], - [ new Int8Array( vals ), isInt8Array ], - [ new Uint16Array( vals ), isUint16Array ], - [ new Uint32Array( vals ), isUint32Array ], - [ new Uint8Array( vals ), isUint8Array ], - [ new Uint8ClampedArray( vals ), isUint8ClampedArray ] - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ][ 1 ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - for ( j = 0; j < buf.length; j++ ) { - t.strictEqual( buf[ j ], expected[ i ][ 0 ][ j ], 'returns expected element ' + j + ' for ' + dtypes[ i ] ); - } - } - t.end(); -}); - -tape( 'the function returns ndarray data buffers (large allocations)', function test( t ) { - var expected; - var dtypes; - var vals; - var buf; - var i; - - dtypes = [ - 'binary', - 'bool', - 'complex64', - 'complex128', - 'float64', - 'float32', - 'generic', - 'int16', - 'int32', - 'int8', - 'uint16', - 'uint32', - 'uint8', - 'uint8c' - ]; - vals = []; - for ( i = 0; i < 1e6; i++ ) { - vals.push( 0 ); - } - expected = [ - isBuffer, - isBooleanArray, - isComplex64Array, - isComplex128Array, - isFloat64Array, - isFloat32Array, - isArray, - isInt16Array, - isInt32Array, - isInt8Array, - isUint16Array, - isUint32Array, - isUint8Array, - isUint8ClampedArray - ]; - for ( i = 0; i < dtypes.length; i++ ) { - buf = buffer( dtypes[ i ], vals.length ); - t.strictEqual( expected[ i ]( buf ), true, 'returns expected value type for ' + dtypes[ i ] ); - } - t.end(); -}); - -tape( 'if provided an unknown/unsupported data type, the function returns `null`', function test( t ) { - var dtypes; - var i; - - dtypes = [ - 'buffer', - 'buf', - 'float', - 'double', - 'single', - 'int', - 'integer', - 'uint', - 'uinteger', - 'byte', - 'bits' - ]; - for ( i = 0; i < dtypes.length; i++ ) { - t.strictEqual( buffer( dtypes[ i ], 10 ), null, 'returns expected value for ' + dtypes[ i ] ); - } - t.end(); -});