From 1f3f1ceb33e96062389c232fed53e32e1a8ad791 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 04:26:33 +0000 Subject: [PATCH 001/120] Auto-generated commit eacd99cca03041e76066e515885a6c122e43292f --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 297 ++++++ index.d.ts | 108 ++ index.mjs | 4 + index.mjs.map | 1 + package.json | 41 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3650 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..ef054e9 --- /dev/null +++ b/README.md @@ -0,0 +1,297 @@ + + +# iterator2array + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Create (or fill) an array from an iterator. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +``` + +#### iterator2array( iterator\[, out]\[, mapFcn\[, thisArg]] ) + +Creates (or fills) an array from an `iterator`. + +```javascript +import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; + +var opts = { + 'iter': 10 +}; + +var arr = iterator2array( randu( opts ) ); +// returns +``` + +By default, the function creates and fills a generic `array`. To fill an array-like `object`, provide an `out` argument. + +```javascript +import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; +import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; + +var out = new Float64Array( 10 ); + +var arr = iterator2array( randu(), out ); +// returns + +var bool = ( out === arr ); +// returns true +``` + +To invoke a function for each iterated value, provide a callback function. + +```javascript +import array2iterator from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-to-iterator@esm/index.mjs'; + +function fcn( v ) { + return v * 10.0; +} + +var arr = iterator2array( array2iterator( [ 1, 2, 3, 4 ] ), fcn ); +// returns [ 10.0, 20.0, 30.0, 40.0 ] +``` + +The invoked function is provided two arguments: + +- `value`: iterated value +- `index`: iterated value index + +```javascript +import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; +import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; + +function fcn( v, i ) { + return v * (i+1); +} + +var arr = iterator2array( randu(), new Float64Array( 10 ), fcn ); +// returns +``` + +To set the callback function execution context, provide a `thisArg`. + +```javascript +import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; +import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; + +function fcn( v ) { + this.count += 1; + return v * 10.0; +} + +var ctx = { + 'count': 0 +}; + +var arr = iterator2array( randu(), new Float64Array( 10 ), fcn, ctx ); +// returns + +var count = ctx.count; +// returns 10 +``` + +
+ + + + + +
+ +## Notes + +- If provided an output array, the function fills the output array with iterated values. +- Iteration stops when an output array is full **or** an iterator finishes; whichever comes first. +- By providing an output typed array, one avoids the temporary memory allocation when using the built-in `TypedArray.from`. + +
+ + + + + +
+ +## 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..e0e83e8 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,108 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; +import { Collection } from '@stdlib/types/object'; + +// Define a union type representing both iterable and non-iterable iterators: +type Iterator = Iter | IterableIterator; + +/** +* Map function invoked for each iterated value. +* +* @returns iterator value +*/ +type Nullary = () => any; + +/** +* Map function invoked for each iterated value. +* +* @param value - iterated value +* @returns iterator value +*/ +type Unary = ( value: any ) => any; + +/** +* Map function invoked for each iterated value. +* +* @param value - iterated value +* @param index - iterated value index +* @returns iterator value +*/ +type Binary = ( value: any, index: number ) => any; + +/** +* Map function invoked for each iterated value. +* +* @param value - iterated value +* @param index - iterated value index +* @returns iterator value +*/ +type MapFunction = Nullary | Unary | Binary; + +/** +* Creates (or fills) an array from an iterator. +* +* @param iterator - source iterator +* @param mapFcn - function to invoke for each iterated value +* @param thisArg - execution context +* @returns output array +* +* @example +* var randu = require( `@stdlib/random/iter/randu` ); +* +* var iter = randu({ +* 'iter': 10 +* }); +* +* var arr = iterator2array( iter ); +* // returns +*/ +declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length + +/** +* Creates (or fills) an array from an iterator. +* +* @param iterator - source iterator +* @param out - output array +* @param mapFcn - function to invoke for each iterated value +* @param thisArg - execution context +* @returns output array +* +* @example +* var Float64Array = require( `@stdlib/array/float64` ); +* var randu = require( `@stdlib/random/iter/randu` ); +* +* var iter = randu({ +* 'iter': 10 +* }); +* +* var out = new Float64Array( 10 ); +* var arr = iterator2array( iter, out ); +* // returns +*/ +declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length + + +// EXPORTS // + +export = iterator2array; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4d8ad8f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var i=e,a=t,o=r,l=n,m=s;var d=function(){var e,t,r,n,s,d,u,f;if(e=arguments[0],arguments.length>1)if(a(arguments[1])){if(n=arguments[1],arguments.length>2){if(!i(r=arguments[2]))throw new TypeError(m("invalid argument. Callback argument must be a function. Value: `%s`.",r));t=arguments[3]}}else{if(!i(r=arguments[1]))throw new TypeError(m("invalid argument. Callback argument must be a function. Value: `%s`.",r));t=arguments[2]}if(!o(e))throw new TypeError(m("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",e));if(u=-1,void 0===n){if(n=[],r){for(;u+=1,!(f=e.next()).done;)n.push(r.call(t,f.value,u));return n}for(;!(f=e.next()).done;)n.push(f.value);return n}if(s=n.length,d=l(n).setter,r){for(;u\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["isFunction","require$$0","isCollection","require$$1","isIteratorLike","require$$2","arraylike2object","require$$3","format","require$$4","lib","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","TypeError","next","done","push","call","value","setter"],"mappings":";;ybAsBA,IAAIA,EAAaC,EACbC,EAAeC,EACfC,EAAiBC,EACjBC,EAAmBC,EACnBC,EAASC,EA4Gb,IC1FAC,EDQA,WACC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKlB,EAAciB,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAMpB,EADNa,EAAMM,UAAW,IAEhB,MAAM,IAAIE,UAAWb,EAAQ,uEAAwEK,IAEtGD,EAAUO,UAAW,QAEhB,CAEN,IAAMnB,EADNa,EAAMM,UAAW,IAEhB,MAAM,IAAIE,UAAWb,EAAQ,uEAAwEK,IAEtGD,EAAUO,UAAW,GAGvB,IAAMf,EAAgBO,GACrB,MAAM,IAAIU,UAAWb,EAAQ,kGAAmGG,IAGjI,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASW,QACNC,MAGPT,EAAIU,KAAMX,EAAIY,KAAMb,EAASM,EAAEQ,MAAOT,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASW,QACNC,MAGPT,EAAIU,KAAMN,EAAEQ,OAEb,OAAOZ,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMV,EAAkBQ,GAAMa,OACzBd,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASW,QACNC,OAGPP,EAAKF,EAAKG,EAAGJ,EAAIY,KAAMb,EAASM,EAAEQ,MAAOT,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASW,QACNC,OAGPP,EAAKF,EAAKG,EAAGC,EAAEQ,OAEhB,OAAOZ"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..9e3b765 --- /dev/null +++ b/package.json @@ -0,0 +1,41 @@ +{ + "name": "@stdlib/array-from-iterator", + "version": "0.0.0", + "description": "Create (or fill) an array from an iterator.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/array-from-iterator.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdtypes", + "utils", + "util", + "utilities", + "utility", + "typed", + "array", + "arr", + "typed-array", + "typed array", + "iterator", + "iterate", + "iteration", + "iter", + "to", + "convert", + "fill", + "map" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d04e790 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From 3d80f482c3fe4535608af605c27dff0fbb562abd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 23:13:00 +0000 Subject: [PATCH 002/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index e7cb270..719a507 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -67,20 +67,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00P2o', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 03e1d3d..c6f8006 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 8ae6df91ef0a02ddb0c7c8a3d9e444193de2d22f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:34:08 +0000 Subject: [PATCH 003/120] Remove files --- index.d.ts | 108 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2802 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4d8ad8f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var i=e,a=t,o=r,l=n,m=s;var d=function(){var e,t,r,n,s,d,u,f;if(e=arguments[0],arguments.length>1)if(a(arguments[1])){if(n=arguments[1],arguments.length>2){if(!i(r=arguments[2]))throw new TypeError(m("invalid argument. Callback argument must be a function. Value: `%s`.",r));t=arguments[3]}}else{if(!i(r=arguments[1]))throw new TypeError(m("invalid argument. Callback argument must be a function. Value: `%s`.",r));t=arguments[2]}if(!o(e))throw new TypeError(m("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",e));if(u=-1,void 0===n){if(n=[],r){for(;u+=1,!(f=e.next()).done;)n.push(r.call(t,f.value,u));return n}for(;!(f=e.next()).done;)n.push(f.value);return n}if(s=n.length,d=l(n).setter,r){for(;u\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["isFunction","require$$0","isCollection","require$$1","isIteratorLike","require$$2","arraylike2object","require$$3","format","require$$4","lib","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","TypeError","next","done","push","call","value","setter"],"mappings":";;ybAsBA,IAAIA,EAAaC,EACbC,EAAeC,EACfC,EAAiBC,EACjBC,EAAmBC,EACnBC,EAASC,EA4Gb,IC1FAC,EDQA,WACC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKlB,EAAciB,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAMpB,EADNa,EAAMM,UAAW,IAEhB,MAAM,IAAIE,UAAWb,EAAQ,uEAAwEK,IAEtGD,EAAUO,UAAW,QAEhB,CAEN,IAAMnB,EADNa,EAAMM,UAAW,IAEhB,MAAM,IAAIE,UAAWb,EAAQ,uEAAwEK,IAEtGD,EAAUO,UAAW,GAGvB,IAAMf,EAAgBO,GACrB,MAAM,IAAIU,UAAWb,EAAQ,kGAAmGG,IAGjI,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASW,QACNC,MAGPT,EAAIU,KAAMX,EAAIY,KAAMb,EAASM,EAAEQ,MAAOT,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASW,QACNC,MAGPT,EAAIU,KAAMN,EAAEQ,OAEb,OAAOZ,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMV,EAAkBQ,GAAMa,OACzBd,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASW,QACNC,OAGPP,EAAKF,EAAKG,EAAGJ,EAAIY,KAAMb,EAASM,EAAEQ,MAAOT,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASW,QACNC,OAGPP,EAAKF,EAAKG,EAAGC,EAAEQ,OAEhB,OAAOZ"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d04e790..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 986b7665d6a09776944a6dbedeb6c3b0d8694a2b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 07:34:54 +0000 Subject: [PATCH 004/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 135 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 439 ---- 37 files changed, 2722 insertions(+), 3922 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2b9dfda..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T22:51:43.757Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 2244f0c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index a417732..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d73b959..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType any[] - // iterator2array( iter, times10 ); // $ExpectType any[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType any[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 2f6bdff..e0e83e8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44c7500 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;kcAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 719a507..0000000 --- a/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00P2o', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - set = arraylike2object( out ).setter; - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index c6f8006..6634a89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..65a9848 --- /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 d48e137..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From a31da6c32b1426132abc62e929f8f0a4995805d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 18:45:43 +0000 Subject: [PATCH 005/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index e7cb270..719a507 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -67,20 +67,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00P2o', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 03e1d3d..c6f8006 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 0e08403d447bc32caf02c377f487b4dd97768d73 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 11:56:48 +0000 Subject: [PATCH 006/120] Remove files --- index.d.ts | 108 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2802 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44c7500..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;kcAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 65a9848..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From cb7b63c8a8faa9b37e570c2f984cd6fdcd389da0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 11:57:47 +0000 Subject: [PATCH 007/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 135 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 439 ---- 37 files changed, 2722 insertions(+), 3922 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a4ddd41..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:41:32.852Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 2244f0c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index a417732..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d73b959..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType any[] - // iterator2array( iter, times10 ); // $ExpectType any[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType any[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 2f6bdff..e0e83e8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44c7500 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;kcAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 719a507..0000000 --- a/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00P2o', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - set = arraylike2object( out ).setter; - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index c6f8006..6634a89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9bb7e6f --- /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 d48e137..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From e37e13c57d2075418cf0637a6468efdc0dc494a0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 18:50:16 +0000 Subject: [PATCH 008/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index e7cb270..719a507 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -67,20 +67,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00P2o', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 03e1d3d..c6f8006 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 3a2d39087b704d7d1c1dee4bc455710727d181cb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:22:23 +0000 Subject: [PATCH 009/120] Remove files --- index.d.ts | 108 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2802 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44c7500..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;kcAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9bb7e6f..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From b8ebbac51c1af579d9d1228676ded7906ef4e1f8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 6 Jul 2022 19:23:17 +0000 Subject: [PATCH 010/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 135 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 439 ---- 36 files changed, 2722 insertions(+), 3887 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 2244f0c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index a417732..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d73b959..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType any[] - // iterator2array( iter, times10 ); // $ExpectType any[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType any[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 2f6bdff..e0e83e8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..44c7500 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;kcAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 719a507..0000000 --- a/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00P2o', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - set = arraylike2object( out ).setter; - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index c6f8006..6634a89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2db5e1d --- /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 d48e137..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From a88b139adc2040569e56326f61144fa23345925d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:57:47 +0000 Subject: [PATCH 011/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index e7cb270..719a507 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -67,20 +67,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00P2o', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 03e1d3d..c6f8006 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From c9ca2c54beadc9c7202b3fa3840c18ba525c8e05 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:43:11 +0000 Subject: [PATCH 012/120] Remove files --- index.d.ts | 108 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2802 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 44c7500..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;kcAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2db5e1d..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From df69e8949a09cd7c62c8c0dc0ae304b0e0f0941d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 14:43:57 +0000 Subject: [PATCH 013/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 135 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 439 ---- 37 files changed, 2722 insertions(+), 3961 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 7212d81..0000000 --- a/.gitattributes +++ /dev/null @@ -1,33 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 19d9177..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:43:43.308Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 2244f0c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index a417732..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d73b959..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType any[] - // iterator2array( iter, times10 ); // $ExpectType any[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType any[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 2f6bdff..e0e83e8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..abcb81b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 719a507..0000000 --- a/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00P2o', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - set = arraylike2object( out ).setter; - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index c6f8006..6634a89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..75c09a7 --- /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 d48e137..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 917baf221fbbcfbf670ec0ea095f12a210f1ecde Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:49:14 +0000 Subject: [PATCH 014/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index e7cb270..719a507 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -67,20 +67,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00P2o', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 03e1d3d..c6f8006 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From bb00e23d7c3ddbad2b99e068e2278b00587d09e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 14:11:50 +0000 Subject: [PATCH 015/120] Remove files --- index.d.ts | 108 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2802 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abcb81b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 75c09a7..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 63d9dfea8b10a2d9610222072452661200d75471 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 14:12:36 +0000 Subject: [PATCH 016/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 135 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 439 ---- 37 files changed, 2722 insertions(+), 3977 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6996555..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:43:52.963Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 2244f0c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index a417732..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d73b959..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType any[] - // iterator2array( iter, times10 ); // $ExpectType any[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType any[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 2f6bdff..e0e83e8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..abcb81b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 719a507..0000000 --- a/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00P2o', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - set = arraylike2object( out ).setter; - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index c6f8006..6634a89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d719396 --- /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 d48e137..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From d0d5eae3f9a27e6fe84f070b4d2e6029f1c5d99e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Sep 2022 20:09:10 +0000 Subject: [PATCH 017/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index e7cb270..719a507 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -67,20 +67,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00P2o', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 03e1d3d..c6f8006 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 159298ce6ea1f3d74314acad1544c03fc0c36e8a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Sep 2022 22:11:07 +0000 Subject: [PATCH 018/120] Remove files --- index.d.ts | 108 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2802 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abcb81b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d719396..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a226294d11cbd4c69675e317bb5cdada8996d1c0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Sep 2022 22:12:04 +0000 Subject: [PATCH 019/120] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 135 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 439 ---- 36 files changed, 2722 insertions(+), 3976 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index a417732..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d73b959..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType any[] - // iterator2array( iter, times10 ); // $ExpectType any[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType any[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 2f6bdff..e0e83e8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..abcb81b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 719a507..0000000 --- a/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00P2o', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - set = arraylike2object( out ).setter; - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index c6f8006..6634a89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a992a02 --- /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 d48e137..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 2c396b168ea48eab789a57fd990610f91975f094 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:53:18 +0000 Subject: [PATCH 020/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index e7cb270..719a507 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -67,20 +67,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00P2o', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 03e1d3d..c6f8006 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From a5d7fbbbba75709ab6c5bc801912080fab0fba7e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 19:52:07 +0000 Subject: [PATCH 021/120] Remove files --- index.d.ts | 108 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2802 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abcb81b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a992a02..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 66850a7cd260fd2470a98a3973ace6f01ad274ad Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 19:52:58 +0000 Subject: [PATCH 022/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 135 -- package.json | 65 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 439 ---- 37 files changed, 2722 insertions(+), 3977 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 8978746..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T02:11:30.060Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index a417732..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d73b959..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType any[] - // iterator2array( iter, times10 ); // $ExpectType any[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType any[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 2f6bdff..e0e83e8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..abcb81b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 719a507..0000000 --- a/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00P2o', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - set = arraylike2object( out ).setter; - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index c6f8006..6634a89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7d8c13a --- /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 d48e137..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From ec464ac91738814f5453b68d8116960ba2fdf2e5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:25:46 +0000 Subject: [PATCH 023/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index e7cb270..719a507 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -67,20 +67,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00P2o', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 03e1d3d..c6f8006 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From bcd3b6ad7fbae41e263a8f1abd1683069dc4a39a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 19:05:10 +0000 Subject: [PATCH 024/120] Remove files --- index.d.ts | 108 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2802 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abcb81b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,QAEhB,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,GAGvB,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,EAER,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,EAIR,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,EAER,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7d8c13a..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 247b20d376e2a891f6ac54b7436058ac71dc1fce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 19:06:10 +0000 Subject: [PATCH 025/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 135 - package.json | 65 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 439 --- 37 files changed, 4077 insertions(+), 3977 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0ead83a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:56:55.056Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0b676c6..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: '33 21 * * 5' - - # 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index a417732..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d73b959..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType any[] - // iterator2array( iter, times10 ); // $ExpectType any[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType any[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 2f6bdff..e0e83e8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..abcb81b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,MACK,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,CAEF,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,CACP,CACD,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,CACP,CAGD,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,CACP,CACD,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 719a507..0000000 --- a/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00P2o', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - set = arraylike2object( out ).setter; - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index c6f8006..6634a89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..87c8535 --- /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 d48e137..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 194e6b4a3799f5ba0d13166af6f5b725278f2aac Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:41:57 +0000 Subject: [PATCH 026/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index e7cb270..719a507 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -67,20 +67,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00P2o', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 03e1d3d..c6f8006 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 9d70fcb81111641a0d2098d4d6f206323675d063 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 08:53:06 +0000 Subject: [PATCH 027/120] Remove files --- index.d.ts | 108 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4157 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abcb81b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,MACK,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,CAEF,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,CACP,CACD,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,CACP,CAGD,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,CACP,CACD,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 87c8535..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From ab8dd60b88875c738760f2bc84ead64e0e54f1b5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 08:54:10 +0000 Subject: [PATCH 028/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 135 - package.json | 65 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 439 --- 37 files changed, 4077 insertions(+), 3998 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 11e577e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T22:58:31.577Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0b676c6..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: '33 21 * * 5' - - # 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index a417732..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d73b959..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType any[] - // iterator2array( iter, times10 ); // $ExpectType any[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType any[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 2f6bdff..e0e83e8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..abcb81b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,MACK,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,CAEF,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,CACP,CACD,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,CACP,CAGD,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,CACP,CACD,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 719a507..0000000 --- a/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00P2o', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - set = arraylike2object( out ).setter; - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index c6f8006..6634a89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..671a35c --- /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 d48e137..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From bcd1ed4b9e710e3c110e428d19a1756ff7e43e5a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 04:40:27 +0000 Subject: [PATCH 029/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index e7cb270..719a507 100644 --- a/lib/main.js +++ b/lib/main.js @@ -24,7 +24,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isCollection = require( '@stdlib/assert-is-collection' ); var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -67,20 +67,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00P2o', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 621f43c..7ad502a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From ebed1dea2bd885a1efc305a99ff5f13aafe3ffbd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:45:55 +0000 Subject: [PATCH 030/120] Remove files --- index.d.ts | 108 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4157 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abcb81b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,MACK,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,CAEF,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,CACP,CACD,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,CACP,CAGD,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,CACP,CACD,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 671a35c..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From f2e5f07f247f144a4fa41322efa68bc8bd03ccef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 18:46:47 +0000 Subject: [PATCH 031/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 135 - package.json | 65 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 439 --- 37 files changed, 4077 insertions(+), 4003 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 39c32e2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T02:47:08.875Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0b676c6..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: '33 21 * * 5' - - # 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index a417732..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d73b959..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType any[] - // iterator2array( iter, times10 ); // $ExpectType any[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType any[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 2f6bdff..e0e83e8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..abcb81b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,MACK,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,CAEF,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,CACP,CACD,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,CACP,CAGD,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,CACP,CACD,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 719a507..0000000 --- a/lib/main.js +++ /dev/null @@ -1,135 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var arraylike2object = require( '@stdlib/array-base-arraylike2object' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00P2o', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - set = arraylike2object( out ).setter; - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 7ad502a..6634a89 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-arraylike2object": "^0.0.x", - "@stdlib/assert-is-collection": "^0.0.x", - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-iterator-like": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x", - "@stdlib/types": "^0.0.x" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.x", - "@stdlib/array-float64": "^0.0.x", - "@stdlib/array-to-iterator": "^0.0.x", - "@stdlib/assert-is-array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/complex-float32": "^0.0.x", - "@stdlib/complex-imagf": "^0.0.x", - "@stdlib/complex-realf": "^0.0.x", - "@stdlib/random-iter-randu": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..868fa9f --- /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 d48e137..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 081893ecfd2fa354a76cb87bb129254ce0d55973 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Jul 2023 16:20:35 +0000 Subject: [PATCH 032/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..b50b031 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00P2n', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00P2o', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 9b6221c..afd9efc 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.0.8", "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 6ac7a2a4234f063b73c498acc72624af249772d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Jul 2023 16:46:39 +0000 Subject: [PATCH 033/120] Remove files --- index.d.ts | 108 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4157 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index abcb81b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-arraylike2object@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function i(){var i,o,l,d,f,m,a,h;if(i=arguments[0],arguments.length>1)if(r(arguments[1])){if(d=arguments[1],arguments.length>2){if(!e(l=arguments[2]))throw new TypeError(n("00P2n",l));o=arguments[3]}}else{if(!e(l=arguments[1]))throw new TypeError(n("00P2n",l));o=arguments[2]}if(!t(i))throw new TypeError(n("00P2o",i));if(a=-1,void 0===d){if(d=[],l){for(;a+=1,!(h=i.next()).done;)d.push(l.call(o,h.value,a));return d}for(;!(h=i.next()).done;)d.push(h.value);return d}if(f=d.length,m=s(d).setter,l){for(;a\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tset = arraylike2object( out ).setter;\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","arraylike2object","setter"],"mappings":";;ycAoDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAP,EAAWQ,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAL,EAAMK,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,MACK,CAEN,IAAMG,EADNT,EAAMM,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASX,IAEvCD,EAAUO,UAAW,EACrB,CAEF,IAAMM,EAAgBd,GACrB,MAAM,IAAIY,UAAWC,EAAQ,QAASb,IAGvC,GADAM,GAAK,OACQ,IAARH,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCI,GAAK,IACLC,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMf,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAEvC,OAAOH,CACP,CACD,OACCI,EAAIP,EAASe,QACNC,MAGPb,EAAIc,KAAMV,EAAEY,OAEb,OAAOhB,CACP,CAGD,GAFAC,EAAMD,EAAIM,OACVJ,EAAMe,EAAkBjB,GAAMkB,OACzBnB,EAAM,CACV,KAAQI,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGJ,EAAIgB,KAAMjB,EAASM,EAAEY,MAAOb,IAE1C,OAAOH,CACP,CACD,KAAQG,EAAIF,EAAI,IACfE,GAAK,IACLC,EAAIP,EAASe,QACNC,OAGPX,EAAKF,EAAKG,EAAGC,EAAEY,OAEhB,OAAOhB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 868fa9f..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From b0ef75d4e1ed4be06f5c203946eed6dce75c3e04 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Jul 2023 16:47:43 +0000 Subject: [PATCH 034/120] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 439 -- 36 files changed, 6210 insertions(+), 4166 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0b676c6..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: '33 21 * * 5' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index e926b20..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index d73b959..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType any[] - // iterator2array( iter, times10 ); // $ExpectType any[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType any[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 2f6bdff..e0e83e8 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1b862a3 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(){var m,l,a,f,h,j,p,c,v;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(f=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00P2n",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00P2n",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00P2o",m));if(c=-1,void 0===f){if(f=[],a){for(;c+=1,!(v=m.next()).done;)f.push(a.call(l,v.value,c));return f}for(;!(v=m.next()).done;)f.push(v.value);return f}if(h=f.length,p=o(f),j=t(f)?i(p):n(p),a){for(;c\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;iuBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index b50b031..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00P2n', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00P2o', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index afd9efc..6d40169 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.0.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.0.1", - "@stdlib/array-base-setter": "^0.0.1", - "@stdlib/array-dtype": "^0.0.6", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-to-iterator": "^0.0.6", - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float32": "^0.0.7", - "@stdlib/complex-imagf": "^0.0.1", - "@stdlib/complex-realf": "^0.0.1", - "@stdlib/random-iter-randu": "^0.0.6", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3f95169 --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From b67858200e7a2ae1ba9a7b12e5b32b1fdbd186db Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 02:30:39 +0000 Subject: [PATCH 035/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..6a18731 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c,Mz', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 9b6221c..afd9efc 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.0.8", "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 3d630d0a8280df1bcf607c1e8f772b2550101333 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 02:42:35 +0000 Subject: [PATCH 036/120] Remove files --- index.d.ts | 108 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6290 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 e0e83e8..0000000 --- a/index.d.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Iterator as Iter, IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/object'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: any ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: any, index: number ) => any; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn?: MapFunction, thisArg?: any ): Array; // tslint:disable-line:max-line-length - -/** -* Creates (or fills) an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn?: MapFunction, thisArg?: any ): Collection; // tslint:disable-line:max-line-length - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1b862a3..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(){var m,l,a,f,h,j,p,c,v;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(f=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00P2n",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00P2n",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00P2o",m));if(c=-1,void 0===f){if(f=[],a){for(;c+=1,!(v=m.next()).done;)f.push(a.call(l,v.value,c));return f}for(;!(v=m.next()).done;)f.push(v.value);return f}if(h=f.length,p=o(f),j=t(f)?i(p):n(p),a){for(;c\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00P2n', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00P2o', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;iuBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3f95169..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c43a6916f71715f8de0746252cc34108966c9e3f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 17 Aug 2023 02:43:36 +0000 Subject: [PATCH 037/120] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 439 -- 39 files changed, 6210 insertions(+), 4166 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0b676c6..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: '33 21 * * 5' - - # 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index e926b20..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index 53a3c2d..d8e4f80 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ef8dedd --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,c,v;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(c=-1,void 0===p){if(p=[],a){for(;c+=1,!(v=m.next()).done;)p.push(a.call(l,v.value,c));return p}for(;!(v=m.next()).done;)p.push(v.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;c\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;iuBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6a18731..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c,Mz', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index afd9efc..6d40169 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.0.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.0.1", - "@stdlib/array-base-setter": "^0.0.1", - "@stdlib/array-dtype": "^0.0.6", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-to-iterator": "^0.0.6", - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float32": "^0.0.7", - "@stdlib/complex-imagf": "^0.0.1", - "@stdlib/complex-realf": "^0.0.1", - "@stdlib/random-iter-randu": "^0.0.6", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ef7ecde --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From f4379fa01ca19c400fefb95d2c90a7c1e2067188 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 24 Aug 2023 10:10:26 +0000 Subject: [PATCH 038/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..6a18731 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c,Mz', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 9b6221c..afd9efc 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.0.8", "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From f07ab75385d588b744a26e0bd5b7d908beeac1df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 24 Aug 2023 10:20:54 +0000 Subject: [PATCH 039/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6337 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 d8e4f80..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = () => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ef8dedd..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,c,v;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(c=-1,void 0===p){if(p=[],a){for(;c+=1,!(v=m.next()).done;)p.push(a.call(l,v.value,c));return p}for(;!(v=m.next()).done;)p.push(v.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;c\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;iuBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ef7ecde..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e5f488ab342bcc6bacb3113beca5932d5c00ad59 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 24 Aug 2023 10:21:55 +0000 Subject: [PATCH 040/120] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 439 -- 39 files changed, 6210 insertions(+), 4166 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0b676c6..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: '33 21 * * 5' - - # 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 + + ```
@@ -232,7 +225,7 @@ for ( i = 0; i < arr.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]. @@ -294,9 +287,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index e926b20..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index c297063..1efce70 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ef8dedd --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,c,v;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(c=-1,void 0===p){if(p=[],a){for(;c+=1,!(v=m.next()).done;)p.push(a.call(l,v.value,c));return p}for(;!(v=m.next()).done;)p.push(v.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;c\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;iuBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6a18731..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c,Mz', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index afd9efc..6d40169 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.6", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.0.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.0.1", - "@stdlib/array-base-setter": "^0.0.1", - "@stdlib/array-dtype": "^0.0.6", - "@stdlib/assert-is-collection": "^0.0.8", - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-iterator-like": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/array-float64": "^0.0.6", - "@stdlib/array-to-iterator": "^0.0.6", - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-float32": "^0.0.7", - "@stdlib/complex-imagf": "^0.0.1", - "@stdlib/complex-realf": "^0.0.1", - "@stdlib/random-iter-randu": "^0.0.6", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ee54aa6 --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 1a8063aec8ad2d158d9b5e6402469350223c2f29 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:02:37 +0000 Subject: [PATCH 041/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..6a18731 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c,Mz', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index f351c24..c6f8038 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.0", "@stdlib/assert-is-iterator-like": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 0889bfe5c75292335d999688752f921835b64bf1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:34:19 +0000 Subject: [PATCH 042/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6337 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 1efce70..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ef8dedd..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.0.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.0.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,c,v;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(c=-1,void 0===p){if(p=[],a){for(;c+=1,!(v=m.next()).done;)p.push(a.call(l,v.value,c));return p}for(;!(v=m.next()).done;)p.push(v.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;c\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;iuBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ee54aa6..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 838f2b819c72507735dd7d0b5fc90d3a28207642 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:36:15 +0000 Subject: [PATCH 043/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 439 -- 40 files changed, 6210 insertions(+), 4201 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 3901ab3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0b676c6..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: '33 21 * * 5' - - # 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 + + ```
@@ -243,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -305,9 +298,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index e926b20..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index c297063..1efce70 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f9e629e --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6a18731..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c,Mz', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index c6f8038..1da27bc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-iterator-like": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^0.1.0", - "@stdlib/random-iter-randu": "^0.0.6", - "@stdlib/utils-noop": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..11ae9e7 --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 119240c2ea877bfe61e5bab43ce52547355d4c74 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:47:35 +0000 Subject: [PATCH 044/120] 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 1d43829..a0173cf 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.1.0-esm/index.mjs'; ``` #### iterator2array( iterator\[, out]\[, mapFcn\[, thisArg]] ) @@ -171,7 +171,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.1.0-esm/index.mjs'; var opts; var arr; From 6f59ce0b3a623fa1cac328e2d6043c2cce4492e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:47:36 +0000 Subject: [PATCH 045/120] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a0173cf..2a71d7e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-from-iterator/tags). For example, + ```javascript import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.1.0-esm/index.mjs'; ``` @@ -171,7 +176,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.1.0-esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; var opts; var arr; From 18551d4d822805026f293ef293936b9300a2bb62 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 17:02:32 +0000 Subject: [PATCH 046/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..6a18731 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c,Mz', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 41e555e..56a470c 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.0", "@stdlib/assert-is-iterator-like": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From a8219ff2139f72c88e1f4ba74c262777d23b9425 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:30:18 +0000 Subject: [PATCH 047/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6337 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 1efce70..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f9e629e..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 11ae9e7..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5bcf6911a33c4be39eab3b6bb1dcaaba2c57945a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 02:33:27 +0000 Subject: [PATCH 048/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 439 -- test/test.js | 439 -- 42 files changed, 6210 insertions(+), 4699 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c870def..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:28:43.777Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0b595d7..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: '33 21 * * 5' - - # 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 + + ```
@@ -243,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -305,9 +298,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index e926b20..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index c297063..1efce70 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f9e629e --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6a18731..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c,Mz', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 56a470c..1da27bc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-iterator-like": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^0.1.0", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/utils-noop": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ddf892a --- /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 8a0664f..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 1a789fb2082052170488d079960682271e464f34 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 20:07:38 +0000 Subject: [PATCH 049/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..6a18731 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c,Mz', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 1526249..cc67624 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 4a22fcef646b55b62aec2d7c18d8eda29eb0a608 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:32:12 +0000 Subject: [PATCH 050/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6337 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 1efce70..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f9e629e..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ddf892a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cade71ab20dc7cc3c8c7b03645135ccbed1bf756 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:35:28 +0000 Subject: [PATCH 051/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 439 -- test/test.js | 439 -- 41 files changed, 6210 insertions(+), 4698 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0b595d7..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: '33 21 * * 5' - - # 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 + + ```
@@ -243,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -305,9 +298,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index e926b20..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index c297063..1efce70 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9c3eb56 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6a18731..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c,Mz', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index cc67624..1da27bc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.0", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^0.1.0", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..01474a9 --- /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 8a0664f..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 417c6bdaa7e0cf1096443fc1af3f99d76acfa804 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 17:51:26 +0000 Subject: [PATCH 052/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..6a18731 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c,Mz', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 05b2b5d..10943cb 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 47905ceb5f69ec930f76f66ca64fde7101bbdd63 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:38:38 +0000 Subject: [PATCH 053/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6337 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 1efce70..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9c3eb56..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 01474a9..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cf9ce6b5e0bbad23229b5b7897c6947c2c47e66d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 02:42:28 +0000 Subject: [PATCH 054/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 6210 insertions(+), 4301 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d32ccd3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:48:45.238Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0b595d7..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: '33 21 * * 5' - - # 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 + + ```
@@ -243,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -305,9 +298,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index e926b20..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index c297063..1efce70 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9c3eb56 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6a18731..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c,Mz', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 10943cb..1da27bc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9e8b176 --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From f2689a28ba8e568719824cd855032c5c959a9756 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 13:58:05 +0000 Subject: [PATCH 055/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..6a18731 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b,GJ', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c,Mz', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index de4b8a7..fd4cb11 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 302579dc7c3567e16a20e95c3b5fe55d37bbbc5f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:15:57 +0000 Subject: [PATCH 056/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6337 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 1efce70..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9c3eb56..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9e8b176..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8c8c2d459064a7cd698a7be8eb4f3552430aa06b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:18:15 +0000 Subject: [PATCH 057/120] 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 | 57 +- benchmark/benchmark.js | 130 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 6210 insertions(+), 4296 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a6030df..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T05:53:16.281Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0b595d7..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: '33 21 * * 5' - - # 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 + + ```
@@ -243,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -305,9 +298,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 5e95e5b..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index e926b20..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index c297063..1efce70 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9c3eb56 --- /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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6a18731..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b,GJ', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c,Mz', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index fd4cb11..1da27bc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0d3be2f --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From fa085a0712eaea0406b5323ba7017e2bd64f0a64 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:18:40 +0000 Subject: [PATCH 058/120] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fed4c76..e0674d4 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From cdd13fbf26fd412dff28f1bb7378b338741aecee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:58:04 +0000 Subject: [PATCH 059/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6337 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 1efce70..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9c3eb56..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 e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b,GJ",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b,GJ",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c,Mz",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b,GJ', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c,Mz', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,WAAYZ,IAE1CD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,WAAYd,IAG1C,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0d3be2f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d26f12f13bcd9eb036edc243a00b198d0080f9ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 14:58:25 +0000 Subject: [PATCH 060/120] 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 | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 43 files changed, 6210 insertions(+), 4302 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e223558..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:22:06.696Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0ea4324..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: '33 21 * * 5' - - # 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 + + ```
@@ -243,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -305,9 +298,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index e926b20..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index c297063..1efce70 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8313b3b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function l(){var l,m,d,f,u,c,j,p,v;if(l=arguments[0],arguments.length>1)if(t(arguments[1])){if(f=arguments[1],arguments.length>2){if(!e(d=arguments[2]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[3]}}else{if(!e(d=arguments[1]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[2]}if(!r(l))throw new TypeError(o("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",l));if(p=-1,void 0===f){if(f=[],d){for(;p+=1,!(v=l.next()).done;)f.push(d.call(m,v.value,p));return f}for(;!(v=l.next()).done;)f.push(v.value);return f}if(u=f.length,j=a(f),c=s(f)?n(j):i(j),d){for(;p\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;2vBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,kGAAmGd,IAGjI,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 9bc5963..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index e0674d4..1da27bc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a988a17 --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 2cf5ea673572cc82471727e6868784ec561f7c74 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:18:09 +0000 Subject: [PATCH 061/120] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fed4c76..e0674d4 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From e9dfd4795d61393ad2597eaeea02e18d12c89568 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:45:31 +0000 Subject: [PATCH 062/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6337 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 1efce70..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/iter/randu` ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8313b3b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function l(){var l,m,d,f,u,c,j,p,v;if(l=arguments[0],arguments.length>1)if(t(arguments[1])){if(f=arguments[1],arguments.length>2){if(!e(d=arguments[2]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[3]}}else{if(!e(d=arguments[1]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[2]}if(!r(l))throw new TypeError(o("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",l));if(p=-1,void 0===f){if(f=[],d){for(;p+=1,!(v=l.next()).done;)f.push(d.call(m,v.value,p));return f}for(;!(v=l.next()).done;)f.push(v.value);return f}if(u=f.length,j=a(f),c=s(f)?n(j):i(j),d){for(;p\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;2vBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,kGAAmGd,IAGjI,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a988a17..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 059202167f335db664c1e768491fb956c69a4b80 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:45:50 +0000 Subject: [PATCH 063/120] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 6210 insertions(+), 4301 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0ea4324..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: '33 21 * * 5' - - # 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 + + ```
@@ -243,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -305,9 +298,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index e926b20..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[esm-url]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8313b3b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function l(){var l,m,d,f,u,c,j,p,v;if(l=arguments[0],arguments.length>1)if(t(arguments[1])){if(f=arguments[1],arguments.length>2){if(!e(d=arguments[2]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[3]}}else{if(!e(d=arguments[1]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[2]}if(!r(l))throw new TypeError(o("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",l));if(p=-1,void 0===f){if(f=[],d){for(;p+=1,!(v=l.next()).done;)f.push(d.call(m,v.value,p));return f}for(;!(v=l.next()).done;)f.push(v.value);return f}if(u=f.length,j=a(f),c=s(f)?n(j):i(j),d){for(;p\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;2vBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,kGAAmGd,IAGjI,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 9bc5963..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index e0674d4..1da27bc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..50befce --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From bce6604e96fc058c5fdeef015b033e2b604b3622 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 08:52:53 +0000 Subject: [PATCH 064/120] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fed4c76..e0674d4 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From c940c776e23b0ab193bfcfba2641985b80f809dd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:17:02 +0000 Subject: [PATCH 065/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6337 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8313b3b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function l(){var l,m,d,f,u,c,j,p,v;if(l=arguments[0],arguments.length>1)if(t(arguments[1])){if(f=arguments[1],arguments.length>2){if(!e(d=arguments[2]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[3]}}else{if(!e(d=arguments[1]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[2]}if(!r(l))throw new TypeError(o("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",l));if(p=-1,void 0===f){if(f=[],d){for(;p+=1,!(v=l.next()).done;)f.push(d.call(m,v.value,p));return f}for(;!(v=l.next()).done;)f.push(v.value);return f}if(u=f.length,j=a(f),c=s(f)?n(j):i(j),d){for(;p\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;2vBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,kGAAmGd,IAGjI,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 50befce..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0a2fa4052a3f67975486f4efa588c48c32fd5d70 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 14:17:22 +0000 Subject: [PATCH 066/120] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 43 files changed, 6210 insertions(+), 4307 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0ea1323..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T06:13:32.818Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0ea4324..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8313b3b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function l(){var l,m,d,f,u,c,j,p,v;if(l=arguments[0],arguments.length>1)if(t(arguments[1])){if(f=arguments[1],arguments.length>2){if(!e(d=arguments[2]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[3]}}else{if(!e(d=arguments[1]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[2]}if(!r(l))throw new TypeError(o("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",l));if(p=-1,void 0===f){if(f=[],d){for(;p+=1,!(v=l.next()).done;)f.push(d.call(m,v.value,p));return f}for(;!(v=l.next()).done;)f.push(v.value);return f}if(u=f.length,j=a(f),c=s(f)?n(j):i(j),d){for(;p\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;2vBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,kGAAmGd,IAGjI,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 9bc5963..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index e0674d4..1da27bc 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.1.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.1.0", - "@stdlib/array-base-setter": "^0.1.0", - "@stdlib/array-dtype": "^0.1.0", - "@stdlib/assert-is-collection": "^0.1.0", - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-iterator-like": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.1.1", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/complex-float32": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8a7505f --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 6d566fba1655eb17fe7e0acbde55d05728167981 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 00:55:47 +0000 Subject: [PATCH 067/120] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 59a1e7f..b9a02a7 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.0", "@stdlib/assert-is-function": "^0.2.0", "@stdlib/assert-is-iterator-like": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1" }, "devDependencies": { From 816805a4509d0b9c195d16e0abb3a54225de5f03 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:18:15 +0000 Subject: [PATCH 068/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6337 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8313b3b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.1.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.1.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function l(){var l,m,d,f,u,c,j,p,v;if(l=arguments[0],arguments.length>1)if(t(arguments[1])){if(f=arguments[1],arguments.length>2){if(!e(d=arguments[2]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[3]}}else{if(!e(d=arguments[1]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[2]}if(!r(l))throw new TypeError(o("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",l));if(p=-1,void 0===f){if(f=[],d){for(;p+=1,!(v=l.next()).done;)f.push(d.call(m,v.value,p));return f}for(;!(v=l.next()).done;)f.push(v.value);return f}if(u=f.length,j=a(f),c=s(f)?n(j):i(j),d){for(;p\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;2vBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,kGAAmGd,IAGjI,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8a7505f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c65fd0538672cd39220fbb2c284eb6ffa8780944 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:19:14 +0000 Subject: [PATCH 069/120] 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 | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 68 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 6210 insertions(+), 4310 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 55822cd..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..11f9d3b --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function l(){var l,m,d,f,u,c,j,p,v;if(l=arguments[0],arguments.length>1)if(t(arguments[1])){if(f=arguments[1],arguments.length>2){if(!e(d=arguments[2]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[3]}}else{if(!e(d=arguments[1]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[2]}if(!r(l))throw new TypeError(o("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",l));if(p=-1,void 0===f){if(f=[],d){for(;p+=1,!(v=l.next()).done;)f.push(d.call(m,v.value,p));return f}for(;!(v=l.next()).done;)f.push(v.value);return f}if(u=f.length,j=a(f),c=s(f)?n(j):i(j),d){for(;p\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;2vBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,kGAAmGd,IAGjI,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 9bc5963..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index b9a02a7..74636e8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Create (or fill) an array from an iterator.", "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,47 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.0", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.0", - "@stdlib/array-base-setter": "^0.2.0", - "@stdlib/array-dtype": "^0.2.0", - "@stdlib/assert-is-collection": "^0.2.0", - "@stdlib/assert-is-function": "^0.2.0", - "@stdlib/assert-is-iterator-like": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0", - "@stdlib/types": "^0.3.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/array-float64": "^0.2.0", - "@stdlib/array-to-iterator": "^0.1.0", - "@stdlib/assert-is-array": "^0.2.0", - "@stdlib/complex-float32": "^0.2.0", - "@stdlib/complex-imagf": "^0.2.0", - "@stdlib/complex-realf": "^0.2.0", - "@stdlib/random-iter-randu": "^0.1.0", - "@stdlib/utils-noop": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..2eda247 --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From d8390224ba12397c6503d1a4cfc5e7fd80d7b92b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:15:11 +0000 Subject: [PATCH 070/120] 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 6948de8..daa6998 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.0-esm/index.mjs'; ``` #### iterator2array( iterator\[, out]\[, mapFcn\[, thisArg]] ) @@ -171,7 +171,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.0-esm/index.mjs'; var opts; var arr; From 5d76dd066e28b23e5a068d110d39bbd52adb6c1b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:15:11 +0000 Subject: [PATCH 071/120] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index daa6998..e9af071 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-from-iterator/tags). For example, + ```javascript import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.0-esm/index.mjs'; ``` @@ -171,7 +176,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.0-esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; var opts; var arr; From 9a8bf4c95d5f183d41462072de18fed7688835fc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 19:40:16 +0000 Subject: [PATCH 072/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index ddc3e4c..cb4c0d6 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.1", "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 5e8d5bfc31c0897beb3e567e2fb66d4e1d29bc4b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:47:16 +0000 Subject: [PATCH 073/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6337 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 11f9d3b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.0-esm/index.mjs";import a from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.1.0-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function l(){var l,m,d,f,u,c,j,p,v;if(l=arguments[0],arguments.length>1)if(t(arguments[1])){if(f=arguments[1],arguments.length>2){if(!e(d=arguments[2]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[3]}}else{if(!e(d=arguments[1]))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",d));m=arguments[2]}if(!r(l))throw new TypeError(o("invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.",l));if(p=-1,void 0===f){if(f=[],d){for(;p+=1,!(v=l.next()).done;)f.push(d.call(m,v.value,p));return f}for(;!(v=l.next()).done;)f.push(v.value);return f}if(u=f.length,j=a(f),c=s(f)?n(j):i(j),d){for(;p\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;2vBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,uEAAwEZ,IAEtGD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,kGAAmGd,IAGjI,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 2eda247..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ef8da8899e284626d87477bf8be107921fdd11d3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:47:30 +0000 Subject: [PATCH 074/120] 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 | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 4875 insertions(+), 4305 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..0b3dfba --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index cb4c0d6..66fe048 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-to-iterator": "^0.2.0", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/random-iter-randu": "^0.2.0", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..400c295 --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 53be4f2a2b32bb1f915c925d950a7e58b27eee86 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:29:29 +0000 Subject: [PATCH 075/120] 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 1fd8419..42fc0f3 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.1-esm/index.mjs'; ``` #### iterator2array( iterator\[, out]\[, mapFcn\[, thisArg]] ) @@ -171,7 +171,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.1-esm/index.mjs'; var opts; var arr; From ba3a1cb3d6bbddeda871dead0d13d03eb135b07f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:29:30 +0000 Subject: [PATCH 076/120] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 42fc0f3..be09e49 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-from-iterator/tags). For example, + ```javascript import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.1-esm/index.mjs'; ``` @@ -171,7 +176,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.1-esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; var opts; var arr; From d1b926995faad6fcfb7f784d32f0f6b2024b2e01 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 08:09:38 +0000 Subject: [PATCH 077/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 7324fcd..fb5c05f 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.1", "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 99829828e91d2b4edb0448e4111c5871b6ce21a9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 13:53:02 +0000 Subject: [PATCH 078/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0b3dfba..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 400c295..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6d29222b0ed48796a42847445ccb27e63e3f1175 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 13:53:20 +0000 Subject: [PATCH 079/120] 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 | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 43 files changed, 4875 insertions(+), 4307 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 30c62a7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T05:53:48.444Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..22a1c12 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index fb5c05f..66fe048 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-to-iterator": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..72251cf --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From bfbd089adafb929f832fd460b045db45308aebf9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:27:58 +0000 Subject: [PATCH 080/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 7324fcd..fb5c05f 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.1", "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 53f9bdf27eeee5e089c971a9a6decb86f087728e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:55:20 +0000 Subject: [PATCH 081/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 22a1c12..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 72251cf..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From be5a46189a3532e51f6794dcb5aa918fce94a77b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 12:55:32 +0000 Subject: [PATCH 082/120] 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 | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 43 files changed, 4875 insertions(+), 4310 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4f0ec7c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:10:52.068Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..22a1c12 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index fb5c05f..66fe048 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-to-iterator": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..72251cf --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From b85d832d72e85759a8950b959e5bc037ec6359e4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:43:05 +0000 Subject: [PATCH 083/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 7324fcd..fb5c05f 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.1", "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 1a74542a77b4877c5313cbfe6b011c9586370a3c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:07:10 +0000 Subject: [PATCH 084/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 22a1c12..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 72251cf..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2aaf087fe1bac560e45b893f95d54a9c509dddfc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:07:25 +0000 Subject: [PATCH 085/120] 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 | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 4875 insertions(+), 4311 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..22a1c12 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index fb5c05f..66fe048 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-to-iterator": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/complex-float32": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..72251cf --- /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 c8a0ad4..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 7d9f768343ba439756877b08d7cb424f3b813c49 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 08:54:02 +0000 Subject: [PATCH 086/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 7d35cde..b581810 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.1", "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 08fc5ef54ca317ce46eee4d56f8f93700dbe311c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 08:55:31 +0000 Subject: [PATCH 087/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 22a1c12..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 72251cf..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 355ef206977edcf48235426a83d5919ded9f150f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 25 May 2024 08:55:46 +0000 Subject: [PATCH 088/120] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 4875 insertions(+), 4318 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..22a1c12 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index b581810..66fe048 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-to-iterator": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/complex-float32-ctor": "github:stdlib-js/complex-float32-ctor#main", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..72251cf --- /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 8249fab..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 2e06db3b1d282e984d894317763e7ce8b2cf31ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Jul 2024 03:29:04 +0000 Subject: [PATCH 089/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 5bce6be..6ffaf81 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.1", "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 959b64d68e7bfef54545934447d1082dda707c31 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Jul 2024 03:40:10 +0000 Subject: [PATCH 090/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 22a1c12..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 72251cf..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 061dd053fed13d341ee13e46650675e6ce223a28 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Jul 2024 03:40:45 +0000 Subject: [PATCH 091/120] 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 | 89 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 4875 insertions(+), 4406 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..22a1c12 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 6ffaf81..66fe048 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.1", - "@stdlib/array-base-setter": "^0.2.1", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.1", - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/assert-is-iterator-like": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float64": "^0.2.1", - "@stdlib/array-to-iterator": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/complex-float32-ctor": "^0.0.1", - "@stdlib/complex-float32-imag": "github:stdlib-js/complex-float32-imag#main", - "@stdlib/complex-float32-real": "github:stdlib-js/complex-float32-real#main", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..72251cf --- /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 0838edb..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 3e86fa930853358f32a84ad320e290e600224279 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:09:26 +0000 Subject: [PATCH 092/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index 1236ded..fc2350b 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 5404bfee2eb851ebec0b2520fec0589a93942176 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:35:54 +0000 Subject: [PATCH 093/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 22a1c12..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.1-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 72251cf..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7feb74867843a766d17c93181b434d07d55fa5f3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:36:09 +0000 Subject: [PATCH 094/120] 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 | 192 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 4875 insertions(+), 4511 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aeca01 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index fc2350b..27000e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.1", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.2.1", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..105113b --- /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 0838edb..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From ba077b48a1fd8976e8ed9cd5f769e9fb61c6674a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:46:08 +0000 Subject: [PATCH 095/120] Update README.md for ESM bundle v0.2.2 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 663615a..57aafd6 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs'; ``` #### iterator2array( iterator\[, out]\[, mapFcn\[, thisArg]] ) @@ -171,7 +171,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs'; var opts; var arr; From fd148867cbab4d97ec83ac1d4f296dbc7a9e1b3d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Jul 2024 03:46:09 +0000 Subject: [PATCH 096/120] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 57aafd6..cf1a295 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-from-iterator/tags). For example, + ```javascript import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs'; ``` @@ -171,7 +176,7 @@ var count = ctx.count; import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@esm/index.mjs'; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-iter-randu@esm/index.mjs'; -import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@v0.2.2-esm/index.mjs'; +import iterator2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-from-iterator@esm/index.mjs'; var opts; var arr; From 470f072ee0f01260c5577f6b2c175557d66b8f13 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:18:52 +0000 Subject: [PATCH 097/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index e0ed2d9..3e7478a 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From be39e2d88de6346235cfbaacaea3c1b7eae9fff2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 13:14:22 +0000 Subject: [PATCH 098/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2aeca01..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 105113b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From afe77e860b369118735fb5560b886eaaa949226d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 13:14:45 +0000 Subject: [PATCH 099/120] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 138 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 43 files changed, 4875 insertions(+), 4458 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index bbcd5d4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T06:03:51.986Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aeca01 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 3e7478a..27000e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..105113b --- /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 0838edb..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 9ac5813e1c2d7b85afd07637d82c4e899837ed48 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:40:37 +0000 Subject: [PATCH 100/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index b1a1ce5..6002298 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 0e6248bc8f2efec9ec41957959dbc46e583500a2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 13:07:15 +0000 Subject: [PATCH 101/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2aeca01..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 105113b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 05533bb9bb76c0419715f1a5b5349c854f5e400c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 13:07:29 +0000 Subject: [PATCH 102/120] 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 | 192 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 43 files changed, 4875 insertions(+), 4512 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 06b77a7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T06:31:38.868Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aeca01 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 6002298..27000e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..105113b --- /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 0838edb..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From e9536c2c610fad9b7febff2871042ffa288aa68f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Sep 2024 02:14:00 +0000 Subject: [PATCH 103/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index b1a1ce5..6002298 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 717922e0682cf7a695820fd0763fb6ae8951a1ff Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Sep 2024 02:14:26 +0000 Subject: [PATCH 104/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2aeca01..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 105113b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d102ce156ce6c8a968013675891256968d5db020 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Sep 2024 02:14:43 +0000 Subject: [PATCH 105/120] 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 | 226 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 4875 insertions(+), 4545 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7813ee5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value - - index: iterated value index (zero-based) - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aeca01 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 6002298..27000e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..105113b --- /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 0838edb..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From fd352581cf8729573aa2a6a534c4df5d449128a5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 21:23:18 +0000 Subject: [PATCH 106/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index b1a1ce5..6002298 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 8d71e52c8a118010054d391f9af9eb53b5a1eb16 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 21:23:54 +0000 Subject: [PATCH 107/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2aeca01..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 105113b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8ae434d80bfaccac919cd15e04d72aad370ba1c2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 21:24:10 +0000 Subject: [PATCH 108/120] 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 | 227 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 4875 insertions(+), 4546 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9b949e4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value. - - index: iterated value index (zero-based). - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index e6bbb6b..80ab374 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aeca01 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 6002298..27000e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..105113b --- /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 0838edb..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 629ce76df304abe7aff662bcf4f6ab8b076a9bcd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:17:05 +0000 Subject: [PATCH 109/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index b1a1ce5..6002298 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From ff7daa6b735883df63ce6dfe6881d8d88c3775b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:21:12 +0000 Subject: [PATCH 110/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 80ab374..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2aeca01..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 105113b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 353cfe068318a5382d3b528792aeabfb3bef3df3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 21:21:28 +0000 Subject: [PATCH 111/120] 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 | 228 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 4875 insertions(+), 4547 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9b949e4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value. - - index: iterated value index (zero-based). - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index f67bd40..0d5bac2 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aeca01 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 6002298..27000e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..105113b --- /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 0838edb..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 9aca4e1e39e29820a203f8392996677dfb7a59ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Sep 2024 02:43:20 +0000 Subject: [PATCH 112/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index b1a1ce5..6002298 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 0da3fdd4276554cd69e2a0749bb6e99a668e3283 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Sep 2024 02:50:04 +0000 Subject: [PATCH 113/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 0d5bac2..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2aeca01..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 105113b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a43e72a3d704b8c99a214010703de7d36100e5f3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 29 Sep 2024 02:50:19 +0000 Subject: [PATCH 114/120] 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 | 229 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 42 files changed, 4875 insertions(+), 4548 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9b949e4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value. - - index: iterated value index (zero-based). - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index f270c78..de8062c 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator as IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..2aeca01 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 6002298..27000e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..105113b --- /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 0838edb..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 65a33795c7e972d85c002eda4876c13245f2b9e7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 02:23:28 +0000 Subject: [PATCH 115/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index e7c66e1..51778a0 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From d0117a7ff493d24ddb4e25dcc3045b3529188f0b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 02:59:40 +0000 Subject: [PATCH 116/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 de8062c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator as IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2aeca01..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 105113b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d3e6c022562e3006656f2dcf05bb29186bdfc7f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 13 Jan 2025 02:59:55 +0000 Subject: [PATCH 117/120] 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 | 229 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 44 files changed, 4875 insertions(+), 4654 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 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 (97%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 754aeeb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-01-13T02:11:14.176Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 3028c1d..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9b949e4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value. - - index: iterated value index (zero-based). - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index f270c78..de8062c 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator as IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43dd0fe --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 51778a0..27000e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..105113b --- /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 0838edb..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); From 5761848dce5471d86e7a560582f9b684027bda19 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 00:54:39 +0000 Subject: [PATCH 118/120] Transform error messages --- lib/main.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.js b/lib/main.js index 9bc5963..81dd4ba 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); var setter = require( '@stdlib/array-base-setter' ); var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -71,20 +71,20 @@ function iterator2array() { if ( arguments.length > 2 ) { fcn = arguments[ 2 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 3 ]; } } else { fcn = arguments[ 1 ]; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '00p2b', fcn ) ); } thisArg = arguments[ 2 ]; } } if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) ); + throw new TypeError( format( '00p2c', iterator ) ); } i = -1; if ( out === void 0 ) { diff --git a/package.json b/package.json index e7c66e1..51778a0 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 3eb2f43d626e6f20068e7f331267c8cf264e0960 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:01:16 +0000 Subject: [PATCH 119/120] Remove files --- index.d.ts | 155 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5002 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 de8062c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { TypedIterator as Iter, TypedIterableIterator as IterableIterator } from '@stdlib/types/iter'; -import { Collection } from '@stdlib/types/array'; - -// Define a union type representing both iterable and non-iterable iterators: -type Iterator = Iter | IterableIterator; - -/** -* Map function invoked for each iterated value. -* -* @returns iterator value -*/ -type Nullary = ( this: V ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @returns iterator value -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type Binary = ( this: V, value: T, index: number ) => U; - -/** -* Map function invoked for each iterated value. -* -* @param value - iterated value -* @param index - iterated value index -* @returns iterator value -*/ -type MapFunction = Nullary | Unary | Binary; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -declare function iterator2array( iterator: Iterator ): Array; - -/** -* Creates an array from an iterator. -* -* @param iterator - source iterator -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Array; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection ): Collection; - -/** -* Fills an array from an iterator. -* -* @param iterator - source iterator -* @param out - output array -* @param mapFcn - function to invoke for each iterated value -* @param thisArg - execution context -* @returns output array -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var randu = require( '@stdlib/random-iter-randu' ); -* -* function scale( v ) { -* return v * 2.0; -* } -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var out = new Float64Array( 10 ); -* var arr = iterator2array( iter, out, scale ); -* // returns -*/ -declare function iterator2array( iterator: Iterator, out: Collection, mapFcn: MapFunction, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = iterator2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43dd0fe..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 105113b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5744e9f06d3eb875b72f58eba6e2813a4b8ae899 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:01:29 +0000 Subject: [PATCH 120/120] 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 | 229 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.js | 130 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 42 - docs/types/test.ts | 88 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 45 - lib/main.js | 144 - package.json | 69 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 439 -- 44 files changed, 4875 insertions(+), 4657 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 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 (97%) 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 9d20212..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-04-14T00:53:50.213Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 7014bce..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,7 +0,0 @@ - - -We are excited about your pull request, but unfortunately we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 6e7d2da..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,54 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - - # Define job to close all pull requests: - run: - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Close pull request - - name: 'Close pull request' - # Pin action to full length commit SHA corresponding to v3.1.2 - uses: superbrothers/close-pull-request@9c18513d320d7b2c7185fb93396d0c664d5d8448 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 23cbb36..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: '33 21 * * 5' - - # 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 + + ```
@@ -245,7 +236,7 @@ for ( i = 0; i < arr.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]. @@ -310,9 +301,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator +[@stdlib/array/to-iterator]: https://github.com/stdlib-js/array-to-iterator/tree/esm -[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view +[@stdlib/iter/to-array-view]: https://github.com/stdlib-js/iter-to-array-view/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 45141f7..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,130 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isArray = require( '@stdlib/assert-is-array' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var pkg = require( './../package.json' ).name; -var iterator2array = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map', function benchmark( b ) { - var values; - var arr; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); - -bench( pkg+'::fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::map,fill', function benchmark( b ) { - var values; - var arr; - var out; - var i; - - values = array2iterator( [ 1, 2, 3, 4 ] ); - out = [ 0, 0, 0, 0 ]; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = iterator2array( values, out, transform ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( arr ) || arr !== out ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); - - function transform( v, i ) { - return v + i; - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 67b9946..0000000 --- a/branches.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers (see [README][esm-readme]). -- **deno**: [Deno][deno-url] branch for use in Deno (see [README][deno-readme]). -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments (see [README][umd-readme]). - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator" -%% click B href "https://github.com/stdlib-js/array-from-iterator/tree/main" -%% click C href "https://github.com/stdlib-js/array-from-iterator/tree/production" -%% click D href "https://github.com/stdlib-js/array-from-iterator/tree/esm" -%% click E href "https://github.com/stdlib-js/array-from-iterator/tree/deno" -%% click F href "https://github.com/stdlib-js/array-from-iterator/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/from-iterator -[production-url]: https://github.com/stdlib-js/array-from-iterator/tree/production -[deno-url]: https://github.com/stdlib-js/array-from-iterator/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-from-iterator/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-from-iterator/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-from-iterator/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-from-iterator/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-from-iterator/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 55b7932..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import iterator2array from '../docs/types/index'; -export = iterator2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 478010d..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(i,n){return function(){return n||i((n={exports:{}}).exports,n),n.exports}};var c=f(function(y,m){ -var v=require('@stdlib/assert-is-function/dist'),g=require('@stdlib/assert-is-collection/dist'),h=require('@stdlib/assert-is-iterator-like/dist'),b=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-accessor-setter/dist'),p=require('@stdlib/array-base-setter/dist'),w=require('@stdlib/array-dtype/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function q(){var i,n,a,r,s,u,o,t,e;if(i=arguments[0],arguments.length>1)if(g(arguments[1])){if(r=arguments[1],arguments.length>2){if(a=arguments[2],!v(a))throw new TypeError(l('00p2b',a));n=arguments[3]}}else{if(a=arguments[1],!v(a))throw new TypeError(l('00p2b',a));n=arguments[2]}if(!h(i))throw new TypeError(l('00p2c',i));if(t=-1,r===void 0){if(r=[],a){for(;t+=1,e=i.next(),!e.done;)r.push(a.call(n,e.value,t));return r}for(;e=i.next(),!e.done;)r.push(e.value);return r}if(s=r.length,o=w(r),b(r)?u=d(o):u=p(o),a){for(;t\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Iterator argument must be an iterator protocol-compliant object. Value: `%s`.', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = iterator2array;\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 (or fill) an array from an iterator.\n*\n* @module @stdlib/array-from-iterator\n*\n* @example\n* var randu = require( '@stdlib/random-iter-randu' );\n* var iterator2array = require( '@stdlib/array-from-iterator' );\n*\n* var iter = randu({\n* 'iter': 10\n* });\n*\n* var arr = iterator2array( iter );\n* // returns \n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAe,QAAS,8BAA+B,EACvDC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAkB,QAAS,6CAA8C,EACzEC,EAAiB,QAAS,oCAAqC,EAC/DC,EAAS,QAAS,2BAA4B,EAC9CC,EAAQ,QAAS,qBAAsB,EACvCC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,GAAiB,CACzB,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAW,UAAW,CAAE,EACnB,UAAU,OAAS,EACvB,GAAKR,EAAc,UAAW,CAAE,CAAE,GAEjC,GADAW,EAAM,UAAW,CAAE,EACd,UAAU,OAAS,EAAI,CAE3B,GADAD,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,MACM,CAEN,GADAC,EAAM,UAAW,CAAE,EACd,CAACX,EAAYW,CAAI,EACrB,MAAM,IAAI,UAAWJ,EAAQ,uEAAwEI,CAAI,CAAE,EAE5GD,EAAU,UAAW,CAAE,CACxB,CAED,GAAK,CAACR,EAAgBO,CAAS,EAC9B,MAAM,IAAI,UAAWF,EAAQ,kGAAmGE,CAAS,CAAE,EAG5I,GADAO,EAAI,GACCJ,IAAQ,OAAS,CAErB,GADAA,EAAM,CAAC,EACFD,EAAM,CACV,KACCK,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMD,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE3C,OAAOJ,CACR,CACA,KACCK,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,MAGPL,EAAI,KAAMK,EAAE,KAAM,EAEnB,OAAOL,CACR,CAQA,GAPAC,EAAMD,EAAI,OACVG,EAAKT,EAAOM,CAAI,EACXT,EAAiBS,CAAI,EACzBE,EAAMV,EAAgBW,CAAG,EAEzBD,EAAMT,EAAQU,CAAG,EAEbJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGL,EAAI,KAAMD,EAASO,EAAE,MAAOD,CAAE,CAAE,EAE9C,OAAOJ,CACR,CACA,KAAQI,EAAIH,EAAI,IACfG,GAAK,EACLC,EAAIR,EAAS,KAAK,EACb,CAAAQ,EAAE,OAGPH,EAAKF,EAAKI,EAAGC,EAAE,KAAM,EAEtB,OAAOL,CACR,CAKAb,EAAO,QAAUS,ICxGjB,IAAIU,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isCollection", "isIteratorLike", "isAccessorArray", "accessorSetter", "setter", "dtype", "format", "iterator2array", "iterator", "thisArg", "fcn", "out", "len", "set", "dt", "i", "v", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9b949e4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( iterator[, out][, mapFcn[, thisArg]] ) - Creates (or fills) an array from an iterator. - - When invoked, an input function is provided two arguments: - - - value: iterated value. - - index: iterated value index (zero-based). - - If provided an output array, the function fills the output array with - iterated values. - - Iteration stops when an output array is full or an iterator finishes; - whichever comes first. - - Parameters - ---------- - iterator: Object - Source iterator. - - out: ArrayLikeObject (optional) - Output array-like object. - - mapFcn: Function (optional) - Function to invoke for each iterated value. - - thisArg: any (optional) - Execution context. - - Returns - ------- - out: ArrayLikeObject - Output array. - - Examples - -------- - > var opts = { 'iter': 10 }; - > var arr = {{alias}}( {{alias:@stdlib/random/iter/randu}}( opts ) ) - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index dc05dfa..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,88 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 randu = require( '@stdlib/random-iter-randu' ); -import iterator2array = require( './index' ); - -/** -* Multiplies a value by 10. -* -* @param v - iterated value -* @returns new value -*/ -function times10( v: number ): number { - return v * 10.0; -} - - -// TESTS // - -// The function returns an iterator... -{ - const iter = randu(); - iterator2array( iter ); // $ExpectType number[] - // iterator2array( iter, times10 ); // $ExpectType number[] => fails in older TypeScript versions - iterator2array( iter, times10, {} ); // $ExpectType number[] - - const out = new Float64Array( 10 ); - iterator2array( iter, out ); // $ExpectType Collection - iterator2array( iter, out, times10 ); // $ExpectType Collection - iterator2array( iter, out, times10, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not an iterator... -{ - iterator2array( 'abc' ); // $ExpectError - iterator2array( 123 ); // $ExpectError - iterator2array( true ); // $ExpectError - iterator2array( false ); // $ExpectError - iterator2array( {} ); // $ExpectError - iterator2array( [] ); // $ExpectError - iterator2array( null ); // $ExpectError - iterator2array( undefined ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a map function or output array... -{ - const iter = randu(); - iterator2array( iter, 123 ); // $ExpectError - iterator2array( iter, {} ); // $ExpectError - iterator2array( iter, true ); // $ExpectError - iterator2array( iter, false ); // $ExpectError - iterator2array( iter, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a map function (when provided an output array)... -{ - const iter = randu(); - const out = new Float64Array( 10 ); - iterator2array( iter, out, 'abc' ); // $ExpectError - iterator2array( iter, out, 123 ); // $ExpectError - iterator2array( iter, out, [] ); // $ExpectError - iterator2array( iter, out, {} ); // $ExpectError - iterator2array( iter, out, true ); // $ExpectError - iterator2array( iter, out, false ); // $ExpectError - iterator2array( iter, out, null ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const iter = randu(); - iterator2array(); // $ExpectError - iterator2array( iter, [], times10, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index ec75fa0..0000000 --- a/examples/index.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'; - -var Float64Array = require( '@stdlib/array-float64' ); -var randu = require( '@stdlib/random-iter-randu' ); -var iterator2array = require( './../lib' ); - -var opts; -var arr; -var it; -var i; - -function scale( v, i ) { - return v * (i+1); -} - -// Create an iterator for generating uniformly distributed pseudorandom numbers: -opts = { - 'iter': 10 -}; -it = randu( opts ); - -// Fill an array with scaled iterator values: -arr = iterator2array( it, new Float64Array( opts.iter ), scale ); - -for ( i = 0; i < arr.length; i++ ) { - console.log( arr[ i ] ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 97% rename from docs/types/index.d.ts rename to index.d.ts index f270c78..de8062c 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { TypedIterator as Iter, TypedIterableIterator as IterableIterator } from '@stdlib/types/iter'; import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43dd0fe --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-iterator-like@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-assert-is-accessor-array@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessor-setter@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-setter@v0.2.2-esm/index.mjs";import o from"https://cdn.jsdelivr.net/gh/stdlib-js/array-dtype@v0.3.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function m(){var m,l,a,p,f,h,j,v,c;if(m=arguments[0],arguments.length>1)if(s(arguments[1])){if(p=arguments[1],arguments.length>2){if(!e(a=arguments[2]))throw new TypeError(d("00p2b",a));l=arguments[3]}}else{if(!e(a=arguments[1]))throw new TypeError(d("00p2b",a));l=arguments[2]}if(!r(m))throw new TypeError(d("00p2c",m));if(v=-1,void 0===p){if(p=[],a){for(;v+=1,!(c=m.next()).done;)p.push(a.call(l,c.value,v));return p}for(;!(c=m.next()).done;)p.push(c.value);return p}if(f=p.length,j=o(p),h=t(p)?i(j):n(j),a){for(;v\n*/\nfunction iterator2array() {\n\tvar iterator;\n\tvar thisArg;\n\tvar fcn;\n\tvar out;\n\tvar len;\n\tvar set;\n\tvar dt;\n\tvar i;\n\tvar v;\n\n\titerator = arguments[ 0 ];\n\tif ( arguments.length > 1 ) {\n\t\tif ( isCollection( arguments[ 1 ] ) ) {\n\t\t\tout = arguments[ 1 ];\n\t\t\tif ( arguments.length > 2 ) {\n\t\t\t\tfcn = arguments[ 2 ];\n\t\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t\t}\n\t\t\t\tthisArg = arguments[ 3 ];\n\t\t\t}\n\t\t} else {\n\t\t\tfcn = arguments[ 1 ];\n\t\t\tif ( !isFunction( fcn ) ) {\n\t\t\t\tthrow new TypeError( format( '00p2b', fcn ) );\n\t\t\t}\n\t\t\tthisArg = arguments[ 2 ];\n\t\t}\n\t}\n\tif ( !isIteratorLike( iterator ) ) {\n\t\tthrow new TypeError( format( '00p2c', iterator ) );\n\t}\n\ti = -1;\n\tif ( out === void 0 ) {\n\t\tout = [];\n\t\tif ( fcn ) {\n\t\t\twhile ( true ) {\n\t\t\t\ti += 1;\n\t\t\t\tv = iterator.next();\n\t\t\t\tif ( v.done ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tout.push( fcn.call( thisArg, v.value, i ) );\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t\twhile ( true ) {\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tout.push( v.value );\n\t\t}\n\t\treturn out;\n\t}\n\tlen = out.length;\n\tdt = dtype( out );\n\tif ( isAccessorArray( out ) ) {\n\t\tset = accessorSetter( dt );\n\t} else {\n\t\tset = setter( dt );\n\t}\n\tif ( fcn ) {\n\t\twhile ( i < len-1 ) {\n\t\t\ti += 1;\n\t\t\tv = iterator.next();\n\t\t\tif ( v.done ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tset( out, i, fcn.call( thisArg, v.value, i ) );\n\t\t}\n\t\treturn out;\n\t}\n\twhile ( i < len-1 ) {\n\t\ti += 1;\n\t\tv = iterator.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\tset( out, i, v.value );\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nexport default iterator2array;\n"],"names":["iterator2array","iterator","thisArg","fcn","out","len","set","dt","i","v","arguments","length","isCollection","isFunction","TypeError","format","isIteratorLike","next","done","push","call","value","dtype","isAccessorArray","accessorSetter","setter"],"mappings":";;owBAuDA,SAASA,IACR,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAR,EAAWS,UAAW,GACjBA,UAAUC,OAAS,EACvB,GAAKC,EAAcF,UAAW,KAE7B,GADAN,EAAMM,UAAW,GACZA,UAAUC,OAAS,EAAI,CAE3B,IAAME,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,MACK,CAEN,IAAMG,EADNV,EAAMO,UAAW,IAEhB,MAAM,IAAII,UAAWC,EAAQ,QAASZ,IAEvCD,EAAUQ,UAAW,EACrB,CAEF,IAAMM,EAAgBf,GACrB,MAAM,IAAIa,UAAWC,EAAQ,QAASd,IAGvC,GADAO,GAAK,OACQ,IAARJ,EAAiB,CAErB,GADAA,EAAM,GACDD,EAAM,CACV,KACCK,GAAK,IACLC,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMhB,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAEvC,OAAOJ,CACP,CACD,OACCK,EAAIR,EAASgB,QACNC,MAGPd,EAAIe,KAAMV,EAAEY,OAEb,OAAOjB,CACP,CAQD,GAPAC,EAAMD,EAAIO,OACVJ,EAAKe,EAAOlB,GAEXE,EADIiB,EAAiBnB,GACfoB,EAAgBjB,GAEhBkB,EAAQlB,GAEVJ,EAAM,CACV,KAAQK,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGL,EAAIiB,KAAMlB,EAASO,EAAEY,MAAOb,IAE1C,OAAOJ,CACP,CACD,KAAQI,EAAIH,EAAI,IACfG,GAAK,IACLC,EAAIR,EAASgB,QACNC,OAGPZ,EAAKF,EAAKI,EAAGC,EAAEY,OAEhB,OAAOjB,CACR"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index a85dfec..0000000 --- a/lib/index.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'; - -/** -* Create (or fill) an array from an iterator. -* -* @module @stdlib/array-from-iterator -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* var iterator2array = require( '@stdlib/array-from-iterator' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 81dd4ba..0000000 --- a/lib/main.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var isCollection = require( '@stdlib/assert-is-collection' ); -var isIteratorLike = require( '@stdlib/assert-is-iterator-like' ); -var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' ); -var accessorSetter = require( '@stdlib/array-base-accessor-setter' ); -var setter = require( '@stdlib/array-base-setter' ); -var dtype = require( '@stdlib/array-dtype' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Creates (or fills) an array from an iterator. -* -* @param {Iterator} iterator - source iterator -* @param {Collection} [out] - output array -* @param {Function} [mapFcn] - function to invoke for each iterated value -* @param {*} [thisArg] - execution context -* @throws {TypeError} iterator argument must be an iterator -* @throws {TypeError} callback argument must be a function -* @returns {Collection} output array -* -* @example -* var randu = require( '@stdlib/random-iter-randu' ); -* -* var iter = randu({ -* 'iter': 10 -* }); -* -* var arr = iterator2array( iter ); -* // returns -*/ -function iterator2array() { - var iterator; - var thisArg; - var fcn; - var out; - var len; - var set; - var dt; - var i; - var v; - - iterator = arguments[ 0 ]; - if ( arguments.length > 1 ) { - if ( isCollection( arguments[ 1 ] ) ) { - out = arguments[ 1 ]; - if ( arguments.length > 2 ) { - fcn = arguments[ 2 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 3 ]; - } - } else { - fcn = arguments[ 1 ]; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '00p2b', fcn ) ); - } - thisArg = arguments[ 2 ]; - } - } - if ( !isIteratorLike( iterator ) ) { - throw new TypeError( format( '00p2c', iterator ) ); - } - i = -1; - if ( out === void 0 ) { - out = []; - if ( fcn ) { - while ( true ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( true ) { - v = iterator.next(); - if ( v.done ) { - break; - } - out.push( v.value ); - } - return out; - } - len = out.length; - dt = dtype( out ); - if ( isAccessorArray( out ) ) { - set = accessorSetter( dt ); - } else { - set = setter( dt ); - } - if ( fcn ) { - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, fcn.call( thisArg, v.value, i ) ); - } - return out; - } - while ( i < len-1 ) { - i += 1; - v = iterator.next(); - if ( v.done ) { - break; - } - set( out, i, v.value ); - } - return out; -} - - -// EXPORTS // - -module.exports = iterator2array; diff --git a/package.json b/package.json index 51778a0..27000e1 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Create (or fill) an array from an iterator.", "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,48 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessor-setter": "^0.2.2", - "@stdlib/array-base-assert-is-accessor-array": "^0.2.2", - "@stdlib/array-base-setter": "^0.2.2", - "@stdlib/array-dtype": "^0.3.0", - "@stdlib/assert-is-collection": "^0.2.2", - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/assert-is-iterator-like": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-complex64": "^0.3.0", - "@stdlib/array-float64": "^0.2.2", - "@stdlib/array-to-iterator": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/complex-float32-ctor": "^0.0.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/random-iter-randu": "^0.2.1", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..105113b --- /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 0838edb..0000000 --- a/test/test.js +++ /dev/null @@ -1,439 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils-noop' ); -var randu = require( '@stdlib/random-iter-randu' ); -var Float64Array = require( '@stdlib/array-float64' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var array2iterator = require( '@stdlib/array-to-iterator' ); -var Complex64 = require( '@stdlib/complex-float32-ctor' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var iterator2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof iterator2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (callback)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [] ); - }; - } -}); - -tape( 'the function throws an error if provided an iterator argument which is not an iterator (output + callback arguments)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( value, [], noop ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), value ); - }; - } -}); - -tape( 'the function throws an error if provided a callback argument which is not a function (output argument)', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - iterator2array( randu(), [], value ); - }; - } -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( iterator2array, TypeError, 'throws an error' ); - t.end(); -}); - -tape( 'the function creates an array from an iterator', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it ); - expected = values; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports providing a callback to be invoked for each iterated value', function test( t ) { - var expected; - var values; - var actual; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - actual = iterator2array( it, scale ); - expected = [ 1, 4, 9, 16 ]; - - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Float64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (accessors)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - var z1; - var z2; - var i; - - values = [ - new Complex64( 1.0, 2.0 ), - new Complex64( 3.0, 4.0 ), - new Complex64( 5.0, 6.0 ), - new Complex64( 7.0, 8.0 ) - ]; - it = array2iterator( values ); - - out = new Complex64Array( values.length ); - actual = iterator2array( it, out ); - expected = new Complex64Array( values ); - - t.equal( actual, out, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - z1 = actual.get( i ); - z2 = expected.get( i ); - t.equal( realf( z1 ), realf( z2 ), 'returns expected value' ); - t.equal( imagf( z1 ), imagf( z2 ), 'returns expected value' ); - } - t.end(); -}); - -tape( 'the function supports filling a provided output array (short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out ); - expected = new Float64Array( [ 1, 2, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports filling a provided output array (callback)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports filling a provided output array (callback; short iterator)', function test( t ) { - var expected; - var values; - var actual; - var out; - var it; - - values = [ 1, 2 ]; - it = array2iterator( values ); - - out = new Float64Array( 4 ); - actual = iterator2array( it, out, scale ); - expected = new Float64Array( [ 1, 4, 0, 0 ] ); - - t.equal( actual, out, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback', function test( t ) { - var expected; - var actual; - var values; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - actual = iterator2array( it, scale, ctx ); - expected = [ 1, 4, 9, 16 ]; - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'the function supports specifying the evaluation context of a provided callback (output argument)', function test( t ) { - var expected; - var values; - var actual; - var out; - var ctx; - var it; - - values = [ 1, 2, 3, 4 ]; - it = array2iterator( values ); - - ctx = { - 'count': 0 - }; - out = new Float64Array( values.length ); - actual = iterator2array( it, out, scale, ctx ); - expected = new Float64Array( [ 1, 4, 9, 16 ] ); - - t.equal( ctx.count, 4, 'returns expected value' ); - t.deepEqual( actual, expected, 'returns expected value' ); - t.end(); - - function scale( v, i ) { - this.count += 1; // eslint-disable-line no-invalid-this - return v * (i+1); - } -}); - -tape( 'if provided an output argument, the function supports infinite iterators', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ) ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); -}); - -tape( 'if provided an output argument, the function supports infinite iterators (callback)', function test( t ) { - var out = iterator2array( randu(), new Float64Array( 10 ), scale ); - t.equal( out.length, 10, 'has expected length' ); - t.end(); - - function scale( v, i ) { - return v * (i+1); - } -});